Hi Porter,
Andrew already set a few things straight. A few more comments:
When you do the following:
>>a: b: 1
then the set-word! value b: attaches itself to the digit 1, returns its
value, which is consumed by the set-word! a:. Subsequently both words
evaluate to 1. This can be used to cascade assignments, when you want to
intialize a few words to some initial value.
Second rule: REBOL doesn't care about newlines. Newlines do not delimit an
expression.
a: b: 1
is equivalent to
a:
b:
1
In your http-object
>http_object: make object! [
> ; Attributes.
> protocol: 'http
> username:
> password:
> hostaddr:
> filepath:
> pagedata:
username: password: ... pagedata:
all wait for something to attach to ... and it finally arrives:
>
> ; Member Functions.
> get_vals: func [] [
> make block! [
> protocol
> username
> password
> hostaddr
> filepath
> ]
> ]
So, get_vals: is set to the function func [] ..., whereupon get_vals
returns the function, which then becomes the object for pagedata's
attachment and so on, until all the hungry set-word! values, such as
username etc. have attached themselves to the same function.
Now, you go ahead and change everything:
>objPage: make http_object [
> username: "webuser"
> password: "letmein"
> hostaddr: "127.0.0.1"
> filepath: "mysite/default.htm"
>]
in objPage username has now been set to "webuser" and so on. That does not
affect what happens in get_vals, because when you say:
>> a: 1 b: 2 c: 3
== 3
>> make block! [a b c]
== [a b c]
make block! returns the words a, b, c in a block, they have not been
dereferenced. You can now say:
>> block: make block! [a b c]
== [a b c]
>> get first block
== 1
>> get second block
== 2
>> get third block
== 3
and the function get demonstrates that a through c were bound, but not
unbound or deferenced, when the block was made.
We can however say:
>> block: make block! reduce [a b c]
== [1 2 3]
or we can say
>> reduce block: make block! [a b c]
== [1 2 3]
to create a block containing the values in place of the words.
Accordingly you could write get_vals like this:
get_vals: func [] [
make block! reduce [
protocol
username
password
hostaddr
filepath
]
]
and now when you say:
>> objPage/get_vals
== [http "webuser" "letmein" "127.0.0.1" "mysite/default.htm"]
you get something that is closer to your desired result. However, beware of
the first entry, http, this should be 'http. What's going on here? In
get_vals we reduce the block and the lit-word! 'http becomes reduced to a
word as well. That's a problem, which we can solve by saying
get_vals: func [] [
make block! reduce [
to-lit-word! protocol
username
password
hostaddr
filepath
]
]
Now the result of the reduction is a value of type lit-word!:
>> objPage/get_vals
== ['http "webuser" "letmein" "127.0.0.1" "mysite/default.htm"]
note the 'http
or, if you prefer:
>
>print objPage/get_vals
>> print objPage/get_vals
http webuser letmein 127.0.0.1 mysite/default.htm
Thought you may find these comments useful.
;- Elan >> [: - )]