Hi, Mike,

Anton has already given a direct answer, but let me dig deeper.

Mike Loolard 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.
> 
> I tried it like that:
> 
> chickenfarm: make chicken [] array 10
> 
> It doesn't seem to work that way, though ?
> 

What you have written is two distinct expressions:

     chickenfarm: make chicken []

and

     array 10

One of the crucial light-bulbs that went on in my head when I
first began using REBOL is the following:

     REBOL has no syntax!

(other than the low-level lexical syntax for e.g. strings, numbers,
etc., but I keep the sentence short for emphasis and effect.)

All you have in REBOL is values, and when you put a bunch of them
together, you have expressions.  That's all.  So let's look at the
expressions you wrote, step by step.

     chickenfarm:    ; this is a set-word which will take the value
                     ; of the immediatly-following expression
     make            ; use HELP; make wants a TYPE/SAMPLE and a SPEC
     chicken         ; this is an object, so MAKE will create an object
     []              ; ... with this spec, i.e. with the same words
                     ;     as the original chicken with no added words
                     ;     or new values for the same words

At this point, make has a prototype object and an empty spec, so it
can construct a new object just like CHICKEN.  Then, at that point,
the expression following CHICKENFARM: has completed evaluation, so
CHICKENFARM is set to that result.  Now we continue:

     array           ; again, use HELP, to learn that ARRAY wants a
     10              ; size (but the initial value is optional).  So...

At this point, ARRAY has a size (but no initial value, as you didn't
use the /INITIAL refinement) and so happily creates a 10-element
block, with each element being NONE (REBOL's value that means "nothing
here").

I hope I'm not insulting your intelligence with the details above!
Reading through your email, I get the feeling that you may still be
trying to read/write REBOL as if it were some other language, and
just want to suggest a shift in perspective that I found helpful
when I was beginning with REBOL.

-jn-






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

Reply via email to