>Hi, I just have come to a point where a Ctor semantic for objects
>would help a lot. I have several objects (with functions,
>variables etc.) in my script, which are created from a prototype:
>
>obj1: make! Prototype[ ....]
>obj2: make! Prototype[ ....]
>obj3: make! Prototype[ ....]
>
>I want that each objects registers itself as soon as it's seen by
>the interpreter by appending a specific part to a series. This
>constructor should be part of the prototype.
>
>Prototype: make! object
>[
>       Constructor: [ append myObjs objectName ]
>]
>
>Further I would like to have a way to refer to the literal object
>name or to the 'this' object. Things like this/name, this/size,
>this/constructed? etc. would be really nice. What do you think?

There is already a 'this' but it's called 'self..

Prototype: make object! [
    constructor: func [ new-name /local new-object ][
        append myObjs new-object:
            make self [ name: new-name ]
        return new-object
    ]
    name: ""
]

object: prototype/constructor "name"

The names in the block can be obtained by:
  object: first myObjs
  object/name
or even more attributes...
  object/size... 
or traversing the objects...
  foreach object myObjs [ probe object/name ]


...Daan <[EMAIL PROTECTED]>

Reply via email to