Hi
thanks for the comments.
On May 27, 2005, at 12:25 PM, Robert P. Goldman wrote:
I was following up on CL-UNIFICATION based on your email to the cells list, and read over the web site docs. I was left with the question of how to unify together two structures or objects. I see how one can unify a structure (or object) with a template, and how that might be used for ML-style pattern-matching.
But what if you really want to know if two structures themselves unify? Presumably one might want to do something like the following:
(setf x #S(FOO A 42 S NIL D NIL)) (setf y #S(FOO A 42 S NIL D NIL))
where x and y are EQUALP, but not EQ, and you'd like to do
(unify x y)
but this is impossible.
Ooops. Not good.
Is the following correct:
(unify x #T(FOO foo-a (foo-a y) foo-s (foo-s y) foo-d (foo-d y)))
Yes. This would work.
and, if so, is there some less cumbersome way to make this happen? I.e., to have a unification method definition that would say "whenever I unify together a FOO and a FOO, I want to apply this template to the second argument?
You make a very good point.
Right now, the only defined methods for UNIFY with STRUCTURE-OBJECTs are
unify structure-object template unify template structure-object
TRT would be to write a method for
unify structure-object structure-object
This would be a limited method in any case, just testing for equality with EQUALP. E.g. given
(setf x #S(FOO A ?x)) (setf y #S(FOO A 42))
(unify x y)
would return an empty environment. I.e. the unifier would not recur into the slots. In alternative the unifier could generate two subtests
(unify x #T(FOO foo-a (foo-a y) foo-s (foo-s y) foo-d (foo-d y))) (unify #T(FOO foo-a (foo-a x) foo-s (foo-s x) foo-d (foo-d x)) y)
This is needed to ensure cross unifications.
I know I could do away with all of this by invoking implementation dependent code getting the structure slots. But I am kind of against it. As it is the unification code is completely portable. Yet, given enough pressure, I will concede and add the the extra code.
Cheers
Marco
PS. Do subscribe to the mailing lists. They are very low volume, but most announcements and discussions go there.
-- Marco Antoniotti http://bioinformatics.nyu.edu NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 715 Broadway 10th FL fax. +1 - 212 - 998 3484 New York, NY, 10003, U.S.A.