wanted: support for multiple-values in (setf mem-ref)

Bug #1473802 reported by 3b
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CFFI
New
Undecided
Unassigned

Bug Description

It would be nice to be able to define accessors for simple structures that didn't require allocating temporary containers.

For example with

(defcstruct vec3
  (v :float :count 3))

it would be nice to be able to do something like

(with-foreign-object (vecs '(:struct vec3) 1000)
  (loop for i below 1000
        do (multiple-value-bind (x y z) (mem-aref vecs '(:struct vec3) i)
             (setf (mem-aref vecs '(:struct vec3) i) (values z y x)))))

without any allocation in the loop.

Not sure if a type defined to be used like that could be completely general purpose, but it might still be worth having even if it only worked with for example mem-ref/mem-aref. In that case, the user could define a primary type that translates to/from a sequence, and have a parallel type for the specific optimization use case.

Revision history for this message
3b (00003b) wrote :

Probably would require implementation of EXPAND-INTO-FOREIGN-MEMORY as mentioned in the MEM-SET compiler macro, since it can't currently do compile time translation of that even without multiple-values.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.