author | Tony Garnock-Jones <tonygarnockjones@gmail.com> |
Wed, 16 Jan 2019 17:15:58 +0000 | |
changeset 438 | 1fe179d53161 |
parent 105 | 2231377e9295 |
permissions | -rw-r--r-- |
105
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
1 |
see comp.lang.scheme msg id 4596c2d8$0$68976$742ec2ed@news.sonic.net |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
2 |
"Re: let binding" by Ray Dillinger <bear@sonic.net> |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
3 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
4 |
--------------------------------------------------------------------------- |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
5 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
6 |
Pascal Costanza wrote: |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
7 |
> Jeffrey Mark Siskind wrote: |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
8 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
9 |
>>> What about good old reflection, like in 3-Lisp and languages |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
10 |
>>> influenced by 3-Lisp, like Brown, etc.? |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
11 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
12 |
>> I am not sufficiently familiar with 3-Lisp to answer this. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
13 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
14 |
> Very roughly, 3-Lisp (and similar approaches) add an nlambda construct |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
15 |
> that is like lambda, but doesn't evaluate its arguments and gets passed |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
16 |
> a representation of the expression, the lexical environment in which the |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
17 |
> nlambda is called and the respective continuation. So, for example, you |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
18 |
> can implement an if statement with nlambda: |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
19 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
20 |
> (define if (nlambda (exp env cnt) |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
21 |
> (eval (cadr exp) env |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
22 |
> (lambda (res) |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
23 |
> (cond (res (eval (caddr exp) env cnt) |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
24 |
> (else (eval (cadddr exp) env cnt))))))) |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
25 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
26 |
I think before you can throw the above example around, |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
27 |
you have to discuss the extension of 'eval' you're |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
28 |
assuming. I see what it does, but I'm not who |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
29 |
you're trying to explain 3-lisp to. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
30 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
31 |
(explanation for those unfamiliar: in addition to |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
32 |
the nlambda construct that Mr. Constanza is trying |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
33 |
to explain, the above code assumes a version of |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
34 |
'eval' that takes three arguments: an expression, |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
35 |
an environment, and a continuation. The expression |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
36 |
is evaluated in the environment, and then the |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
37 |
continuation is called. If the continuation doesn't |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
38 |
return, then the call to eval doesn't return. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
39 |
Otherwise, it returns what the continuation returns.) |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
40 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
41 |
There's still a problem here, in that sometimes and |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
42 |
for some functions, you want to pass an argument along |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
43 |
to *other* functions, still unevaluated. When you |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
44 |
do so, this model causes you to implicitly pass your |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
45 |
current lexical environment rather than the one that |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
46 |
argument arrived with, and the expression form arrives |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
47 |
at the next function with a lexical environment that |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
48 |
isn't directly useful for evaluating the expression. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
49 |
Rinse & repeat for however great a depth you want to |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
50 |
pass argument expressions lazily, and you get quite |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
51 |
a thorny thicket in which to code. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
52 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
53 |
For a more general solution to the problem that nlambda |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
54 |
attempts to address, every unevaluated argument should |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
55 |
be some kind of entity from which the callee may |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
56 |
extract both the expression and that expression's own |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
57 |
lexical environment, which may be different from the |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
58 |
lexical environment of other expressions in the same |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
59 |
call. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
60 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
61 |
> The IMHO best overview paper is "Control-Related Meta-Level Facilities |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
62 |
> in Lisp" by Jim des Rivieres (in Maes/Nardi, "Meta-Level Architectures |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
63 |
> and Reflection). |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
64 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
65 |
IMNSHO, the best overview paper is barely adequate. This |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
66 |
is memespace that's lying fallow right now because it is |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
67 |
outside the design space of all four of the surviving |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
68 |
major Lisp dialects, and learning this stuff from |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
69 |
overview papers without hands-on experience is like |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
70 |
trying to learn the geography and boulevards of Paris |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
71 |
from a map when you've never been there. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
72 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
73 |
As long as it's lying fallow, we can't expect any advances |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
74 |
in the practice, and darn few in the theory, because |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
75 |
thousands of smart people just don't have their hands and |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
76 |
minds in it every day. All we can expect is the work of |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
77 |
several dozen or maybe a few hundred grad students, and |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
78 |
frankly less and less of that given that most Ph.D |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
79 |
committees see lambda as already pretty thoroughly explored. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
80 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
81 |
> Since you get access to the arguments before they are evaluated, you can |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
82 |
> probably also transform them to the kinds of arguments that you actually |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
83 |
> need. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
84 |
> It would probably be interesting to reflect on variable lookup as such - |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
85 |
> maybe slambda, similar to symbol macros in Common Lisp or R6RS Scheme - |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
86 |
> and values - maybe vlambda. (This doesn't exist, I am just speculating |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
87 |
> here...) |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
88 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
89 |
slambda is a trivial reduction in power from the |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
90 |
nlambda construct you mentioned before, easily |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
91 |
implementable simply as a restriction on its |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
92 |
argument set, and vlambda is already familiar as |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
93 |
the "normal" lambda-form in a call-by-value Lisp |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
94 |
such as Scheme. It is interesting to distinguish |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
95 |
a vlambda form in an otherwise-lazy lisp dialect, |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
96 |
but for the area of memespace people here/today |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
97 |
are knowledgeable about, the ability of nlambda |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
98 |
to handle lazy semantics is more interesting, |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
99 |
counterintuitive, or surprising. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
100 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
101 |
>>> Or for that matter, what about implementing your own evaluator? |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
102 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
103 |
>> That in of itself doesn't allow nonstandard interpretations to be |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
104 |
>> first-class. Without the ability for changing the basis, you can't |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
105 |
>> compose nonstandard interpretations (potentially in different orders) |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
106 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
107 |
Here's the same point I explained above. Composing |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
108 |
nonstandard interpretations requires a lexical |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
109 |
environment to be passed with each *argument*, rather |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
110 |
than with each *call*. If you're passing an environment |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
111 |
with each *call*, it's properly the dynamic environment |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
112 |
rather than the lexical environment. When you pass an |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
113 |
"open" expression to an nlambda form, the system has to |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
114 |
"close" it, attaching the current lexical environment |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
115 |
When you pass an expression that's already closed, it |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
116 |
already has an environment attached, and it doesn't get |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
117 |
a new one. But your nlambda analogue needs to get all |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
118 |
the expressions in closed form, each with an environment |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
119 |
pointer attached. And your closed forms need to be a |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
120 |
data type with accessors that can separately extract |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
121 |
the expression and the lexical environment. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
122 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
123 |
> Very interesting. The term "nonstandard interpretation" led me to |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
124 |
> believe that this is about interpreters (as in "The Art of the |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
125 |
> Interpreter" ;). But this seems to be quite related nevertheless... |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
126 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
127 |
Programming language interpreters are cases of the exact |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
128 |
same kind of interpretation he's talking about above. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
129 |
In fact, programming mathematical interpretation is an |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
130 |
excellent way to find bugs in your math (although you |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
131 |
have to work past the bugs in your programming to be |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
132 |
sure of exactly what you've found). |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
133 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
134 |
But mostly they're much more loosely specified and have a |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
135 |
universe of discourse limited to representable values in |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
136 |
a particular machine's finite memory. On typical computer |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
137 |
approximations of the set of real numbers, not even |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
138 |
commutativity and associativity hold for addition or |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
139 |
multiplication, so it gets very hard to actually prove |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
140 |
anything. |
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
141 |
|
2231377e9295
Bear's notes on nlambda and 3-lisp
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
142 |
Bear |