[array] [syntax] Re: Some other questions
[1/1] from: joel::neely::fedex::com at: 22-Nov-2003 7:45
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
<<quoted lines omitted: 5>>
> 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-
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted