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

Re: Re : set in Scheme



Well, putting my radical hat on, not only is set evil, but also set!. Only 
non-destructive programming practices are safe, and everything else inevitably
leads to disaster.

But back here in the real world, one occasionally wants global variables.
Those you can have via set! and define. I guess the frequency with which 
I use set in Lisp can be best judged by the fact that I hadn't realised 
it was absent in Scheme until reading the original posting on this subject.

There are good reasons for omitting it. First of all, set makes programs
opaque in that one has no idea which variable is getting modified. More to
the point, Scheme dispenses with value cells, so implementing set would be
non-trivial in most Schemes (though Chez Scheme's "boxes" might make it 
easier).

My eyes glaze over when I see two levels of backquote in a macro definition, 
so I don't know how effective the posted  solution is. However, my choice is
the humble property list. Still not terribly structured, but efficiently 
implemented and a bit more modular (different bits of code can use plists
without interfering, so long as they use different pnames). 

Of course, the *right* way to do this is probably a hash table or tree...



Vincent Manis                    | manis@cs.ubc.ca
The Invisible City of Kitezh     | manis@cs.ubc.cdn
Department of Computer Science   | manis@ubc.csnet
University of British Columbia   | {ihnp4!alberta,uw-beaver,uunet}!
<<NOTE NEW ADDRESS>>             |      ubc-cs!manis