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

Re: let and for vs. lambda variations



i'm wrong.  (and Harald's wrong, but only because he believed part
of what i wrote.)

you can't do any of this rewriting (let->lambda, for example) because
you can write

	let ($var = ...) { ... }

in es, but

	@ $var { ... } ...

is illegal.  (for those who care, the parameter list is restricted to
quoted or unquoted words only, and is not glommed.)

i don't want to relax this restriction (it makes the grammar ambiguous
if it is relaxed, that is, if arbitrary words are allowed in parameter
lists), which i'm going to take as a good reason to keep let and friends.

as for implementing local as a function (modulo whatever syntax it needs),
i don't think it can be done, because of the interactions between dynamic
binding, lexical binding, and dynamic variable references (i.e., $$x).

for example, if

	local (var = foo bar) echo $var

is rewritten as

	%local {echo $var} var foo bar

with this definition of 

	fn %local fun var list {
		let (old=$$var) {
			unwind-protect {
				$var = $list
				$fun
			} {
				$var = $old
			}
		}
	}

you get a ``multi-word variable name'' error.  if you change the
``foo bar'' to a single word, you have different problems.

name space collisions are real problems.  es semantics are a little
weird here, because you can refer to lexically scoped variables
with constructs that cannot be fully known at translation time.
(the infamous $$x or $(`foo) operations.)

paul