On 29-Sep-99, [EMAIL PROTECTED] wrote:

>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>> Sent: Wednesday, September 29, 1999 10:13 AM
>> To: [EMAIL PROTECTED]
>> Subject: [REBOL] Constructor semantics? Re:
> 
>> wouldn't self work?
>>>> obj: make object!
> 
>>         val-1: "this is me."
>>         print-val: func [] [print self/val-1]
>> ]
>>>> obj/print-val
>> this is me.
>>>> 
> 
> Hi, well this works but you have to keep the stuff in sync. So
> the problem isn't to put a name into an object but to refer to
> the Rebol-used-name of the object.
> 
> obj: make object
> [
>     append all-objects-we-have self/name
> ]
> 
> This will append 'obj to all-objects-we-have, later than I can
> do:
> 
> forall objs in all-objects-we-have
> [
>     do objs
> ]
> 

I get the point, but there might be some problems.
What would you except the following code to print?

    a: make object! [test1: 1]
    b: make a [test2: 2]
    c: :b

    f: func [obj [object!]] [
      print obj/name
    ]

    f a
    f b
    f c


I guess for a and b it should print 'a and 'b :)
But what about 'c?
After the first three lines, 'b and 'c will "point" to the same object.
Should it print 'b or 'c?

Furthermore, inside the function, all the objects will be called 'obj.

to make it even more tricky, consider this:

    f make object! [test3: 3]

The object doesn't have a name!


Best regards
Thomas Jensen

Reply via email to