Thanks for the tips Chris!
On Thursday 04 January 2007 07:22, Chris Double wrote:
> Both generics may have different implementations of the method
> specialized on 'object' for example. How would you deal with this?
I would normally try to avoid this situation.
> You'd define the 'foo' generic for apples in its vocab. And the 'foo'
> generic for oranges in the oranges vocab. Use USE: to differentiate.
This defeats the purpose of object oriented code. Comparing Smalltalk style OO
with generic functions, Smalltalk wins here; a smalltalker doesn't worry
about two classes having the same method name.
> For the case where you have 'car' and 'aeroplane' and want the 'move'
> generic to work across both you probably should create a file
> containing the 'protocol' for those objects. This would contain the
> generic definitions. This is how some of the Dylan libraries worked
> iirc.
move on car and aeroplane seem similar and it makes sense to have the GENERIC:
go into some protocol spec file.
But what if I also have this:
M: file move ( dir file -- )
defined on a filesystem object. And:
M: window move ( position window -- )
defined on an X11 object.
I don't think those should be a part of the car/aeroplane protocol. However I
may have a program that needs to move cars, aeroplanes, files, and windows.
1 - It would suck to have to litter the code with USE: to switch between which
set of methods I'm accessing.
2 - Making words like move-window or move-file defeats the purpose of a
generic function system and object-orientation in general.
A programming language should not make the programmer think about where the
GENERIC: statement should go. The implementation should keep track of
bookkeeping like that. All a programmer should have to do is define methods
over objects and let the language take care of the rest.
Ed
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk