Re: [stack] Some thoughts on Object Cat

"Daniel Ehrenberg" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
In this system, is there any polymorphism over field names? It looks
like there isn't really. Also, how do you plan to support prototype
OO? In Io, for example, you might do

something := Object clone
something slot := value

But in Cat, or at least the subset I know about, you can only define
procedures, not variables in this way. How do you plan to get around
this?

Dan

On Fri, Apr 18, 2008 at 2:13 PM, Christopher Diggins <[email protected]> wrote:
>
>
>
>
>
>
> In the quest to add objects to Cat I am thinking of doing some rather
>  strange things.
>
>  ==
>
>  1) Adding a new instruction to create an object:
>
>  object : ( -> object)
>
>  2) Adding a new instruction form (any word ending with '+') to
>  indicate adding a field to an object:
>
>  field+ : ('o 'a -> 'o+field:'a)
>
>  This is so that I can support prototype-style object oriented programming.
>
>  3) Adding a new instruction form (any word ending with '?') to
>  indicate a field getter
>
>  field? : ('o -> 'o 'o.field)
>
>  4) Adding a new instruction form (any word ending with '!') to
>  indicate a field setter
>
>  field! : ('o 'o.field -> 'o)
>
>  ==
>
>  So here is how it would look:
>
>  >> object
>  stack: ()
>  >> 0 x+
>  stack: (x=0)
>  >> 0 y+
>  stack: (x=0,y=0)
>  >> 12 x!
>  stack: (x=12,y=0);
>  >> x? 30 + y!
>  stack: (x=12, y=42)
>
>  I love to hear any comments or suggestions. I am really not happy with
>  the syntax of types for adding fields (#2), but it seems like a
>  neccessary evil.
>
>  Christopher Diggins
>  http://www.cdiggins.com
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.