Re: substructure sharing in #'union result
- From: andrew.polonsky@xxxxxxxxx
- Date: Tue, 20 Nov 2007 03:39:15 -0800 (PST)
Thanks for the suggestion, that's essentially what I am trying to do
(using cons instead of objects tho), but I run into the problem
REMOVING the references to variables from those lists when they get
bound. This will happen often, so I want it to be efficient, but it
seems that just going naively through the tree, I will always have to
check whether or not I removed the reference already (because of
substructure sharing between parent and children). So I wonder if
there's any "predictable" behavior that could be exploited.
It seems that there should be an easy way to do this, but I just can't
see it!
Andrew
On Nov 20, 11:30 am, Pascal Costanza <p...@xxxxxxxxx> wrote:
andrew.polon...@xxxxxxxxx wrote:
Hi, I am new to LISP, so I apologize if this is a silly question!
I am wondering if there are any general patterns on when the list
returned by the union function will share substructure with its
arguments. Also, will it be eq to one of them iff the other is nil?
Cltl and the spec don't seem to say anything about this :(
(If it's of interest, the context is this. I am parsing logical
formulas. At each syntax node I have (among other things) a list of
variables free for that subformula. This will be the union of those
in its children. IF I KNEW that the union would preserve the
pointers, I could implement a simple binding mechanism by only
(rplac)ing the leafs in the tree. Alternatively, I could do
substitution explicitly, but then I wanna know what happens to those
lists of variables!)
The entries in sets can be more complex objects than just plain symbols.
Just put CLOS objects representing variables in your sets and modify
some slot representing a binding in each object. The CLOS notion of
unbound slots is even a pretty direct and appropriate way of
representing free variables.
Union uses #'eql for comparison by default, which respects object
identity. So the union of two lists is guaranteed to contain the same
objects (under #'eql) as the original lists. This means that side
effecting slots in those objects gives you the semantics you want, no
matter how union works.
Pascal
--
My website:http://p-cos.net
Common Lisp Document Repository:http://cdr.eurolisp.org
Closer to MOP & ContextL:http://common-lisp.net/project/closer/
.
- Follow-Ups:
- Re: substructure sharing in #'union result
- From: Pascal Costanza
- Re: substructure sharing in #'union result
- References:
- substructure sharing in #'union result
- From: andrew . polonsky
- Re: substructure sharing in #'union result
- From: Pascal Costanza
- substructure sharing in #'union result
- Prev by Date: Re: basic questions
- Next by Date: Re: {fa} TI Explorer LISP Machine parts for $1.00
- Previous by thread: Re: substructure sharing in #'union result
- Next by thread: Re: substructure sharing in #'union result
- Index(es):
Relevant Pages
|
Loading