RE: SOLUTION FOR : How can I add a new children in a node??

Subject: RE: SOLUTION FOR : How can I add a new children in a node??
From: "Frank A. Christoph" <christo@xxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Oct 1999 14:40:40 +0900
I wrote:
> One of the
> neat things about Scheme is that the action of compiling a program is
> (supposed to be) the same as that of just cat'ing it to the standard input
> of a Scheme REPL, so you can actually make your program do things at
> compile-time without having to invoke a preprocessor or
> something. From that
> perspective, redefining an identifier is just a compile-time state change.

I'm getting tired of correcting myself, but this is a big blooper on my
part.

Scheme programs can carry out actions at compile-time, using macros, but not
in the way I implied. The conceptual model of how a "define" expression gets
compiled is that it is just another run-time action, i.e., at run-time, a
cell gets created and the compiled code for that procedure or value gets
assigned to that cell. (An actual compiler may well not implement it this
way, but behaviorally that is how it ought to appear.)

For example, the following program:

  (define (f x) (+ 1 1))
  (display "hello")
  (define g f)
  (g)

does nothing at compile-time. At run-time, it will allocate a cell f, assign
(lambda (x) (+ 1 1)) to it, then print "hello", then allocate a cell g,
assign f to g, and finally return the value 2.

--FAC


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread