[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

object projections and protocol



I'm new to this group and to Dylan, so I apologize if this is old stuff.

If an object B is indistinguishable as a subtype of another object A 
in the sense that for every method applicable to A there is also an
indistinguishable method for B, it would be nice to be able to cast 
a B into an A irregardless of the heterarchy of declared types.  I
am told this is called a 'projection.'

In Dylan projections could be accomplished explicitly using 
the 'as' function.

This would free the implementer from the burden of anticipating the
entire class heterarchy.  It certainly couldn't be expected to be
efficient (which is why it should only be done explicitly via 'as,'
but I have found that I often really want to do this and that there
is no other way around not being able to (independent of surgery on
the type heterarchy).

I suppose the tricky part would be going through all the methods
for which A is an argument and making sure that there is a
corresponding method for B and then building the appropriate
dispatcher.

Anybody wanna shoot this down?

I was told that one alternative to this mess is to move toward a
'protocol-based' system as opposed to an 'object-based' system.
I think I know what that means, but if anybody can point to some
literature, or enlighten me here, I would be much obliged.

thant