Re: SETF for functions returning multiple values.
"David McClain (as dbm at refined-audiometrics dot com)" <[email protected]> Mon, 8 Jun 2026 11:13:44 -0700
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
Heh! This mirrors the discussion we just had. I made my own digits become macro characters so that I can directly handle numbers written like these: +1°23’.23 2026/06/08T11:10:09U+7 520-234-3474 and of course any number can be written with embedded comma or underscore: 1_234.5192_5542_112D0 I love it! Lisp no longer feels like a straightjacket to me. I can just directly type in the numbers as I need them. The only other time in my life where I had such freedom was in my ancient Forth Mount Control Systems on the world’s largest telescopes. - DM > On Jun 8, 2026, at 11:02, Tim Bradshaw (as tfb at tfeb dot org) <[email protected]> wrote: > > (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 _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html