*** Error:
unbound variable: zz
This should work according to my lisp book.
I think this is dynamic scoping
But it doesn't work on my version of schem STk.
Maybe dynamic scoping is forbidden in scheme.
Any help greatly appreciated.
Thanks
-js
>STk> (define (bit x y)
> (let ()
> (set! x 1)
> (set! y zz) y))
>#[undefined]
>STk> (define (blob zz)
> (bit x y))
>#[undefined]
>STk> (blob 7)
>*** Error:
>unbound variable: zz
>This should work according to my lisp book.
>I think this is dynamic scoping
Yup! It is dynamic scoping, and you must be using an OLD Lisp/Lisp book.
Modern Common Lisp doesn't use dynamic scoping any longer.
>But it doesn't work on my version of schem STk.
>Maybe dynamic scoping is forbidden in scheme.
>Any help greatly appreciated.
Scheme has never supported dynamic scoping. As a late comer to the
Lisp/Scheme world, I've yet to want to use dynamic scoping, and it is
my understanding that its use could introduce some truly scary bugs.
So, I'm pretty happy that we don't get to use it any longer.
Hope this helps.
--
Will Hartung - Rancho Santa Margarita. It's a dry heat. vfr...@netcom.com
1990 VFR750 - VFR=Very Red "Ho, HaHa, Dodge, Parry, Spin, HA! THRUST!"
1993 Explorer - Cage? Hell, it's a prison. -D. Duck
yes, it does. however, the default is lexical scope, and you have to
request dynamic scope specially.
certain variables in Common Lisp are defined as dynamic (special) by the
standard, such as the *package*, *read-base*, *print-base*, just to name
three that are very frequently referenced while reading and printing.
#\Erik
--
1,3,7-trimethylxanthine -- a basic ingredient in quality software.
> In article <vfr750E4...@netcom.com>, vfr...@netcom.com (Will Hartung) writes:
> |> (3 posts from John later --- :-)
> |> "John L. Stein" <st...@seas.ucla.edu> writes:
>
> |> Modern Common Lisp doesn't use dynamic scoping any longer.
>
> Wrong. Both lexical and dynamic scoping are available. Up
> to about 1965, the default in most Lisps that had both was
> dynamic. Past that time, the default changed to lexical
> mainly because of run-time efficiency.
Another important consideration was that lexical scoping makes the code
easier to understand, since all variable bindings can be found simply by
looking at the function definition. Dynamic scoping requires knowledge
of the call tree to find variable bindings, so it is a much more tedious
process.
--
Thomas A. Russ, USC/Information Sciences Institute t...@isi.edu
|> Modern Common Lisp doesn't use dynamic scoping any longer.
Wrong. Both lexical and dynamic scoping are available. Up
to about 1965, the default in most Lisps that had both was
dynamic. Past that time, the default changed to lexical
mainly because of run-time efficiency. It was much latter,
circa the discussion on Common Lisp, that lexical scoping
meant closures. In any event, Common Lisp has both but,
since dynamic isn't the default, you the user must whisper
something to the compiler/eval to let it know your intentions.
The way to communicate is with a SPECIAL declaration or
proclimation of the use of DEF{VAR|CONSTANT|PARAMETER}.
Jeff Barnett
>* Will Hartung
>| Modern Common Lisp doesn't use dynamic scoping any longer.
>
>yes, it does. however, the default is lexical scope, and you have to
>request dynamic scope specially.
>
>certain variables in Common Lisp are defined as dynamic (special) by the
>standard, such as the *package*, *read-base*, *print-base*, just to name
>three that are very frequently referenced while reading and printing.
Of course you could write your own dynamic scoping pretty easily in
Scheme. Make all your dynamic variables global and then write a macro
let-dynamic which saves the old value, and then resets it afterwards.