Re: (read-from-string "#.(values) 42")



Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx> writes:

2.4.8.6 Sharpsign Dot

#.foo is read as the object resulting from the evaluation of the
object represented by foo. The evaluation is done during the read
process, when the #. notation is encountered. The #. syntax
therefore performs a read-time evaluation of foo.

I think the wording "the object" can be interpreted to mean
the primary value will be used.

Possibly no real program cares what #.(values) does.
However, something like #.(floor 65536 pi) may occur in a program.
The result of reading this syntax may now be undefined in principle,
but implementations agree that only the primary value gets used.
If you modified CLISP to make #. propagate all values,
then such expressions would begin failing:

*** - READ from #<INPUT CONCATENATED-STREAM #<INPUT STRING-INPUT-STREAM>
#<IO TERMINAL-STREAM>>: dispatch macro character definition for #\.
after #\# may not return 2 values, only one value.

So you would have to either remove this check from CLISP
or onerously require users to write #.(values (floor 65536 pi)).

An EXPLICITLY-VAGUE option may be the safest one.
Users who want a specific behaviour can define their own reader macros.
.



Relevant Pages

  • Re: m4 Problems
    ... The trick is to avoid evaluation of the two conditional parts by quoting ... them at least ONE level more than the enclosing ifdef(). ... will still evaluate `foo' and `bar' at the outter level, ...
    (freebsd-questions)
  • Re: dot meaning
    ... Sometimes explanations are given with respect to ... internal lisp constructs, and sometimes they are given as ... as opposed to foo which represents the global value of a symbol. ... Evaluation times are always confusing. ...
    (comp.lang.lisp)
  • Re: How does macrolet get implemented?
    ... Since FOO is a macro, ... Macroexpansion is part of evaluation. ... precisely, it gets fbound (in the global environment), rather than ... A following (COMPILE 'TEST) will get it compiled for sure. ...
    (comp.lang.lisp)
  • Re: unusual OR syntax
    ... always be the case for a procedural language, ... operators such as OR and AND, operands are evaluated left to right, and evaluation stops as soon as the results of the expression are known. ... true OR foo() - foowill never be called because the expression is true ... it for the reason that it undermines any automatic code optimization - ...
    (comp.lang.php)
  • Re: can a reader macro parse a variable instead of constant?
    ... (+ (first pair) ... Let me simplify this a bit, we'll try and turn #[foo a b c] into ... (mapcar #'foo a b c), so that each of a b and c ... Evaluation can happen at two times: ...
    (comp.lang.lisp)