[plt-scheme] Question on Syntactic Sugar
It is not clear from J.T.'s email whether setq is sometimes used in
the dated psuedo-lisp to introduce bindings for global variables from
within a local scope.
For example, in some systems you can use the following trick to add a
global binding for global-z, *without* ever writing anything like
(define global-z 'to-be-defined)
(let ((x EXP1) (y EXP2))
(set! global-z (list x y)))
I suspect there is a way to get a similar effect using MzScheme's
namespaces, but I do not know what it is.
In any case, I think Dave has the right idea (modulo the need for a
literals list in his syntax-rules form, as he pointed out in a
subsequent email).
I'm just not sure if such a simple replacement of setq with define is
going to be sufficient for J.T.'s purposes.
-Felix
On Nov 1, 2007, at 3:34 PM, Dave Herman wrote:
> Would this get the job done?
>
> (define-syntax setq
> (syntax-rules setq
> [(setq rest ...) (define rest ...)]))
>
> Dave
>
> J.T. Hurley wrote:
>> I've been working on an "overlay" for Scheme that would let a user
>> enter a set of extremely dated pseudo-lisp from a puzzle book as
>> Scheme code in MzScheme.
>> For the most part, this has been trivially easy, just using (define
>> old-term new-term). However, I've hit a huge snag.
>> The old pseudo-lisp uses setq instead of define, and MzScheme throws
>> an error if you use define within in a definition. What would be the
>> easiest way to get around this and create an expression equivalent to
>> (define setq define)?
>> Thank you in advance,
>> J.T.
>> _________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme