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: "T. Kurt Bond" <tkb@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 3 Oct 1999 12:22:52 -0400 (EDT)
Brandon Ibach writes:
> Quoting Aleksandar Bakic <bakicale@xxxxxxxxxxxxxxxxx>:
> > > You could also write (process-children), or just (pc) if you define it:
> > > 
> > >   (define (pc) (process-children))
> > > 
> > > which is what I do.
> > 
> > Sorry if I am a bit off the topic, but can't you define pc like in
> > pure Scheme:
> > 
> > (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.)

To get "pc" to call the procedure that "process-children" was bound to
when "pc" was defined you'd need to do something like this:

    (define pc
      (let ((old-pc process-children))
        (lambda ()
	  (old-pc))))

-- 
T. Kurt Bond, tkb@xxxxxxxxxxxxxxxxxxx


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


Current Thread