[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What #,(foo) does tell, and what it does not

> Now consider
>         (cond-expand
>          ((and srfi-4 srfi-10 srfi-10-4)
>           (define sample-vector '#,(f32 1.0 2.0 3.0))))

Note that mixing "cond-expand" and "#,(...)" as in this example is not
a good practice.  That is because "#," operates at read-time and
cond-expand operates later, at macro-expansion time.  So the
constructor for f32 will be executed regardless of the presence of
srfi-4, srfi-10, and srfi-10-4 (and if "#," is not supported by the
reader, you will get a reader error).

The "#," mechanism requires the user to understand yet another level
of compilation and the time when it is performed (and the model is
already not that simple if you consider forms like "(load ...)",
"(include ...)", and "(eval ...)", and the REPL).