SETF for functions returning multiple values.

"Tim Bradshaw (as tfb at tfeb dot org)" <[email protected]> Mon, 8 Jun 2026 19:02:59 +0100
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
(setf (values p1 p2) <form-returning-two-values>) should work when p1 and p2 are places (the spec talks about this).

If F is a function returning two values, then you can't write a (SETF F) function for it, but you can write a setf expansion pretty easily.  So then you just can say (setf (f ...) (values v1 v2)).

I don't think I've seen this done elsewhere.  Does it strike people as reasonable?

The reason I'm asking is that the delimited-string reading thing I've been cleaning up now lets you control the closing delimiter, so that for instance #D[foo/bar.ldat] might read as the contents of the file foo/bar.ldat (ie the opening and closing delimiters are different now, which they used not to be.

The function which lets you set up handlers is get-dsr-handler and it now returns two values the handler (or NIL) and the closing delimiter (or NIL if it's the same as the opening delimiter).

So I want to be able to say (setf (get-dsr-handler #\[) (values my-handler #\])) say.

--tim

[The actual hidden motivation for this is an utterly perverse usage I thought of: you can make any digit character be an opening delimiter and the closing delimiter for all of them be #\., and with a suitable handler function

? #D1213,456,789.
1213456789

And even

> #16DFFFF FF00 ABCD.
281474959977421

So that's pretty neat.]



_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html