[ENH] Constraint Framework

Peter Smet peter.smet at flinders.edu.au
Thu Jun 10 00:50:53 UTC 1999


One step that would aid in this assertion mechanism and type checking is to
make protocols into first class objects (in essence, a collection of
selectors). I have thought about this before, and while this seems to be
trivial to do using reflection, there are some difficulties. Using protocols
it would be possible to check if a parameter passed to an method implements
the desired protocol. However, the problem is recursive. Inside the method,
the parameter may be sent messages with parameters, and the protocol of
these parameters must also be determined etc. It is important to distinguish
that selectors with the same name are not interchangeable - for example

#do: oneArgBlock and
#do: twoArgBlock

are not plug-compatible, and this can only be determined by looking at the
protocol of the parameters.

So each entry in a Protocol object may need to be a selector, followed by
one or more Protocol objects, representing its aguments. There should also
be a Protocol Any, which is compatible with all Protocols - in essence
reverting to dynamic typing.

It would be nice if methods could be written that take Protocols as
arguments, in which case a good deal of checking could be done by the
compiler before run-time. It seems to me that constraint-solving is ideal
for this kind of problem.


Peter





More information about the Squeak-dev mailing list