# Re: [stack] My proposal for polymorphic/generic/overloaded user functions in Joy

## Dirk-Ulrich Heise — 2001-04-02 06:25:23

    -----Ursprüngliche Nachricht-----

    Von: "John Cowan" <cowan@...>

    An: <concatenative@yahoogroups.com>

    Gesendet: Samstag, 31. März 2001 06:42

    Betreff: [stack] My proposal for polymorphic/generic/overloaded user

    functions in Joy

     > "Dispatch" takes one quotation argument; however, the quotation is *not*

    > executed.  Instead, the strings naming the words of which it consists

    > are concatenated in reverse order with "-" between them, and the symbol

    > table is searched for a defined function with that name.  If it exists,

    > the stack is popped and it is executed.  If no such definition exists,

    > the stack is unconsed and we try again.  When the stack top is a null

    > list, "dispatch" signals an error.

     So, you compose a string and seek an accordingly named function

    every time a method shall be called? Sounds kinda slow.

    In an OOP Extension to Forth, i defined constants for generic method

    names, some way like this:

    0 constant do

    1 constant paint

    2 constant delete

    ...

    and for each object type, i created a list (a VMT) that contained

    the addresses of the words, so namely, the VMT for type point

    would look like

     [ point-do point-paint point-delete ]

    so i only had to do a table lookup. Plus, there was a mechanism

    for name-mangling, like in your scheme, but it would build up

    these tables during compile time so it's faster during runtime.

    If you can't do it in compile-time in Joy, you could do it with

    some "initializer" word during runtime.

    BTW, my OOP-scheme for Forth is not completely satisfying,

    at the moment it's invoked by saying

      args method object

    but it would be better to invoke it in the sequence

      args object method

    for some twisted reason... Actually, at the moment, my objects

    are some kind of "magic" because they perform the dispatch...

    so they don't mix very well with other data. The dispatch magic

    should be part of the method word. (Like in your proposal, if i

    understood it correctly)

    Dirk Heise

    What's a life and where do i get one?

## Dirk-Ulrich Heise — 2001-04-02 13:15:22

    -----Ursprüngliche Nachricht-----

    Von: "Dirk-Ulrich Heise" <hei@...>

    An: <concatenative@yahoogroups.com>

    Gesendet: Montag, 2. April 2001 08:25

    Betreff: Re: [stack] My proposal for polymorphic/generic/overloaded user

    functions in Joy

    ,> If you can't do it in compile-time in Joy, you could do it with

     > some "initializer" word during runtime.

     Oh! I forgot that there are no variables in Joy. So you can't

    accelerate your scheme the way i did in Forth, because you

    can't store the prepared VMT anywhere. Sorry,

    i'm not used to pure functional languages. Forget my

    suggestions.

    Dirk Heise

    What's a life and where do i get one?