Mike wrote:
> 1) If I have an object - how do I create an array of objects with it ?
> for example
>
> chicken: make object! [
> tasty: "wings"
> ]
>
> now I would want to have an array of objects of that type.

>> help array
USAGE:
    ARRAY size /initial value

DESCRIPTION:
     Makes and initializes a series of a given size.
     ARRAY is a function value.

ARGUMENTS:
     size -- Size or block of sizes for each dimension (Type: integer block)

REFINEMENTS:
     /initial -- Specify an initial value for all elements
         value -- Initial value (Type: any)
>> chicken: make object! [
[    tasty: "wings"
[    ]
>> chickenfarm: array/initial 10 chicken
== [
    make object! [
        tasty: "wings"
    ]
    make object! [
        tasty: "wings"
    ]
    make object! [
        t...

> 2) How do you create custom types ?
> I am talking of a way to emulate the typedef behavour in C ?

Not yet directly available in Rebol. :(

> How would you go to create an "enum" type in REBOL ?

Several ways:

>> foo: func [/bar /baz] [probe bar probe baz]
>> foo/bar
true
none
== none
>> foo/bar/baz
true
true
== true

>> MyEnum: [Upper Lower Inbetween]
== [Upper Lower Inbetween]
>> index? find MyEnum 'Lower
== 2

Usually though, you'll find that there's not much need for enums in Rebol.
:)

> 3) Back on objects:
> objects seem to be pretty neat in REBOL - but I didn't find anything about
implementing and using constructor/destructors ?
>
> I know I could manually add a function that serves as constructor each
time I create an object, but is that the way REBOL requires it ?

Here's a constructor:
>> chicken: make object! [
[    tasty: "wings"
[    ]

Looks like you've found it all ready! :)

There's no need for a destructor in Rebol.

> 4) In the same context:
> how do I actually 'free' memory/variables ?

>> x: "A really large string! :)"
== "A really large string! :)"
>> x: none
== none
>> probe x
none
== none

More later.

Andrew J Martin
Speaking in tongues and performing miracles.
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://Valley.150m.com/
-><-

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to