wanted: support for multiple-values in (setf mem-ref)
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-
(loop for i below 1000
do (multiple-
(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.
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.