Martin Gasbichler <xxxxxx@informatik.uni-tuebingen.de> writes:
> # let prog = .< let x = 1 in
> .~ (let m () = let x = 2 in
> .< x >.
> in
> .< .~ (m ()) >.) >.;;
>
Yeah yeah, you're right of course! But still, ...
val prog : ('a, int) code = .<let x_2 = 1 in 2>.
# .! prog;;
- : int = 2
..., the result still is 2! That's the point! Andre seemed to suggest
at the beginning of this thread that either 1 or "no result" would be
sensible results for this example. I think returning "1" is the wrong
thing here, because this seems to contradict lexical scoping
completely. Either return "2" by adding cross-stage persistence (CSE),
or return an error without it as you suggest.
>> Cross-stage persistence still kicks into action, though.
>
> But you don't need it because a macro is a source-to-source
> transformation and UNQUOTE (as SRFI-72 and MetaOCaml provide it)
> already does the trick:
>
> let prog = .< let x = 1 in
> .~ (let m () = let x = .< 2 >. in
> .< .~ x >.
> in
> .< .~ (m ()) >.) >.;;
Sure, you don't need it. But just compare the two code fragments from
above: to achieve the same result without CSP, you have to insert even
more UNQUOTEs and SYNTAX brackets in your macro than before. It gets
even worse, if x is not just a value but a more complicated
expression. With CSE, it is simpler to write macros to achieve the
same result. So why not just allow it? Are there any drawbacks?
-Matthias
--
Matthias Neubauer |
Universität Freiburg, Institut für Informatik | tel +49 761 203 8060
Georges-Köhler-Allee 79, 79110 Freiburg i. Br., Germany | fax +49 761 203 8052