3 ms·
In Common Lisp the way I usually handle this is with an optional arg. If the caller passes in a buffer[0] that's where I put the result; otherwise I allocate on
by dreamcompiler 7y ago
In Common Lisp the way I usually handle this is with an optional arg. If the caller passes in a buffer[0] that's where I put the result; otherwise I allocate one and return it. The more general approach is to accept a continuation argument. One can even do both at the same time by dispatching a generic function on the type of the arg (but in that case the arg cannot be optional unless you write a wrapper function around the generic function.)
[0] Passing buffers around is much less necessary in Lisp than in C-like languages. This is about the times when it still makes sense to do so.