On 3/1/07, Matthew Willis <[EMAIL PROTECTED]> wrote:
> Ed,
>
> All of those are either math-combination's (which don't let you
> specify what types of objects you'd like to do your multiple dispatch
> on) or single dispatching methods that dispatch on the object below
> the top of the stack (in the case of load-literal or JUMPcc).  Still
> no sign of the "out-of-the-box" multiple dispatch functionality :)
>
> The circle is now complete; when I left you, I was but the learner,
> now I am the master!
> Yuuki ;)

Congratulations on your coming of age, Yuuki. We should throw you a
Bar Mitzvah. But as far as multiple dispatch goes, it is basically
possible in Factor within the current OO system if you decide that the
argument on the top of the stack's class is more important that the
second on the stack. For example, if there's a choice between methods
for ( fixnum object -- ) and ( object number -- ) the latter would be
chosen. An example of that is below, implementing a word called ++
which does concatenation or addition, depending on the argument types,
as it works in some languages:

GENERIC: ++
GENERIC: number++
GENERIC: string++

M: number ++ swap number++ ;
M: sequence ++ swap sequence++ ;

M: number number++ + ;
M: string number++ swap number>string append ;

M: number string++ number>string swap append ;
M: string string++ swap append ;

It shouldn't be difficult to make a syntax to automate this with a new
parsing word, if it ends up being useful. It's cool to see different
types of object systems. I'm looking forward to a message passing
system, and it wouldn't be bad to see a more fleshed-out
double/multiple dispatch system either.

Daniel Ehrenberg (LittleDan)

-------------------------------------------------------------------------
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

Reply via email to