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: Brandon Ibach <bibach@xxxxxxxxxxxxxx>
Date: Sun, 3 Oct 1999 22:55:13 -0500
Quoting T. Kurt Bond <tkb@xxxxxxxxxxxxxxxxxxx>:
> Brandon Ibach writes:
> > > (define pc process-children)
> > > 
> >    Yes.  This would bind "pc" to the same procedure object that
> > "process-children" is bound to.  The other form would, theoretically,
> > bind "pc" to a new, zero-argument, procedure object which simply calls
> > the procedure to which "process-children" is bound at the time of the
> > definition.  I would think that a smart Scheme implementation would
> > render these two the same, but I'm not positive.
> 
> Actually, 
> 
>     (define (pc) (process-children))
> 
> will bind pc to a new, zero-argument procedure as you suggested, but
> when called it will actually call the procedure that
> "process-children" is bound to when "pc" is called.  (This is probably
> less of a difference in DSSSL than in Scheme, since DSSSL lacks the
> imperative features of Scheme.)
> 
   I'm fairly sure my take was correct (having gone back now and
checked the relevant portions of the DSSSL spec), but let me know if
I've missed something.  By definition:
	(define (pc) (process-children))      becomes
	(define pc (lambda () (process-children)))
   Lambda effectively "stores" the definition environment, recreating
it when the procedure is called, changing it only by extending it with
bindings for the arguments.  Thus, when the procedure is executed,
"process-children" will be bound to whatever it was bound to at the
time of the definition, even if it has been redefined to something
else in the interim.
   This raises an interesting question.  Is it possible to create a
procedure that will call on the *current* environment, rather than its
stored one?  For instance, in Postscript, I can do:
	/pc { process-children } bind def
which would behave like lambda, in that it would replace all of the
symbols in the procedure with their bound values (via the bind call)
before binding the procedure to the "pc" symbol (via the def).  Or, I
could do the same thing, without the bind, to have the symbol resolved
at execution time.

-Brandon :)


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


Current Thread