[Newbies] where to "put" a unification algorithm...

Roel Wuyts Roel.Wuyts at ulb.ac.be
Fri Feb 16 06:52:21 UTC 2007


You can put it there, yes.

But there is an important design question lurking there. If you put  
the unification method on these classes, what you are really saying  
is: this Smalltalk object can be unified with that Smalltalk object.  
So you are then extending the Smalltalk language with unification.

The alternative is to only have unification methods un your own  
'unifiable objects' hierarchy. In that hierarchy you will probably  
have a class called: CWNumber, which represents numbers in your  
language and which will hold a Smalltalk number.

Which alternative to choose depends on whether, and how deep, you  
want to integrate Smalltalk and your own language. Unless you really  
want to mingle Smalltalk objects within your language, or want  
unification directly accessible at the Smalltalk level without having  
to pass through your language, I would advise the second option.


( If you are interested I have a number of papers I can point you to,  
since I did research on integrating a Prolog in Smalltalk )

On 16 Feb 2007, at 16 February/06:34, Chris Wright wrote:

> I would like to play around with some classes which require
> unification (I know about Prolog/V etc...). I am not sure where to
> "put" the unification algorithm.
>
> It might look like:
>
> anObject unifiesWith: anotherObject in: anEnvironment
>
> ? does that seem like the right sort of selector?
>
> So, to I put that in Number, Strings, Array, (and a class I've made  
> - LogicVar)?
>
> Is it "OK" to extend the functionality of the built-in classes this
> way, or should I derive my own Number, String, Array --- I want to use
> the parser/compiler that Squeak already has, so I want to be able to
> enter:
>
> 5 unifiesWith: 5 in: emptyEnv
>
> On the subject of return values, what's the best way to return more
> than one value? Should I create my own class (UnificationReturnValue)
> (then I could tell it how to respond to ifTrue/ifFalse etc), or should
> I return a collection with indexes for the success-value and the
> environment-value?
>
> Thanks!
>
> Cheers
>
> Chris
>
> -- 
> A/Prof Chris Wright FJFICJ FRACP MBBS
> Medical Director, ICU
> Monash Medical Centre
> Clayton, VIC
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



More information about the Beginners mailing list