home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!agate!anarres.CS.Berkeley.EDU!bh
- From: bh@anarres.CS.Berkeley.EDU (Brian Harvey)
- Newsgroups: comp.lang.pop
- Subject: Re: lvars and standards (was: Re: List and Vector Syntax)
- Date: 7 Jan 1993 23:12:38 GMT
- Organization: University of California, Berkeley
- Lines: 50
- Message-ID: <1iidd6INNa83@agate.berkeley.edu>
- References: <116670041@otter.hpl.hp.com> <C07Bop.DwH@cs.bham.ac.uk> <1993Jan7.154850.16982@syma.sussex.ac.uk>
- NNTP-Posting-Host: anarres.cs.berkeley.edu
-
- ianr@syma.sussex.ac.uk (Ian Rogers) writes:
- >I have met noone who can provide a rational argument for dynamic
- >locals over lexical locals! [...]
- >lvars as default is a Good Thing, the One True Way, there Can Be No
- >Argument!!!!! :-)
-
- I'm not a Pop programmer, but I've been teaching and programming using
- both Logo (dynamic scope) and Scheme (lexical scope) for many years.
- I can see good arguments on both sides. I'm really happy to have both
- languages available to me.
-
- There are two main things that I like about dynamic scope in Logo:
-
- 1. I find that debugging is easier for a beginner, who has no model of
- frames, bindings, and all that, in a dynamically scoped language. When
- an error happens in Logo, the error handler just gives you a Logo prompt
- in the environment where the error happened -- and *all* the relevant
- variables in all the procedures higher up the stack are automatically
- available in the usual way. By contrast, in lexically scoped Scheme, there
- is a special debugging language that has commands to shift focus from one
- environment to another.
-
- 2. It's easy to write control structures like WHILE in Logo because
- expressions are first-class. You say
-
- to while :condition :action
- if not RUN :CONDITION [stop]
- RUN :ACTION
- while :condition :action
- end
-
- The parts in capital letters evaluate an expression given as argument.
- Under dynamic scope, the variables of the procedure that invoked WHILE
- are available. To do something similar in a lexically scoped language
- you have to explicitly create and pass a closure instead of just passing
- the expression:
-
- Logo: while [:x > 0] [make "x :x-1]
-
- Scheme: (while (lambda () (> x 0))
- (lambda () (set! x (- x 1))) )
-
- It's the lambdas I'm objecting to. (Yes, you can use macros so it looks
- nicer, but the Logo way is something a fifth-grader can understand.)
-
-
- These arguments aren't meant to say that dynamic scope is always the right
- thing. Of course if you're trying to write a procedure that returns another
- procedure, lexical scope is very helpful. I'm just reacting to the
- one-sidedness of the previous message.
-