[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NTH-VALUE, some examples
- To: Fahlman @ CMU-CS-C
- Subject: NTH-VALUE, some examples
- From: Kent M. Pitman <KMP @ MIT-MC>
- Date: Thu, 02 Jun 1983 02:15:00 -0000
- Cc: Common-Lisp @ SU-AI
I think the main argument is that it's fine to want to bind values coming
back, but I don't think multiple values will ever have "first class" state
in the language until the set of primitives is rich enough that you aren't
forced to do clumsy things to use them. I currently prefer
(LET ((VSIZE (CADR (MULTIPLE-VALUE-LIST (SEND TERMINAL-IO ':SIZE)))))
...)
to using MULTIPLE-VALUE-BIND for implementing a selector such as this, and
I am very saddened that this conses. I feel that this has the word "cliche"
written all over it.
Style issues aside, this case could be written with MULTIPLE-VALUE-BIND but
the case of
(LET ((X (NTH-VALUE N (FOO)))) ...)
can in fact not be written without consing in any form.
Note further that allowing an NTH-VALUE primitive lends itself to more
portable abstractions. Macros can be written which syntactically appear
to reference a structure, allowing efficient implementation in dialects
supporting multiple values and slightly slower implementations in those
dialects which don't.
A quickie poll of the LispM around now users showed that just under half
(~4) thought it was obvious that there should be an NTH-VALUE
to handle common cases like:
(LET ((VSIZE (NTH-VALUE 1. (SEND TERMINAL-IO ':SIZE)))) ...) ;or :EDGES
(COND ((NTH-VALUE 1. (CATCH-ERROR (EVAL FORM))) ;for effect
...))
About as many (~4) had never wanted such a feature, but these people
admitted not using multiple values much. 1 claimed not to have ever wanted
it but said that it sounded useful, and 2 hit me with arguments about
how people don't want multiple values anyway, they want structures, and
only the compiler should ever know...