A few questions about words
[1/7] from: eric:mccinc at: 19-Oct-2000 13:28
I seem to be misunderstanding the use of words in rebol.
say I had the following code
word1: "This is a word"
word2: 'word1
is there any way using word2 to access and set the value of word1? It seems
to me that I should be able to. I guess what I am asking is if a function
is passed a variable name can us then use that to modify and access the
value. If I am completly off the mark on this one let me know.
Thanks
Eric Merritt
[2/7] from: larry:ecotope at: 19-Oct-2000 10:47
Hi Eric
>> word1: "This is a word"
== "This is a word"
>> word2: 'word1
== word1
>> get word2
== "This is a word"
>> word3: 'word2
== word2
>> get get word3
== "This is a word"
This process can be carried out to any depth.
HTH
-Larry
[3/7] from: ryanc:iesco-dms at: 19-Oct-2000 10:54
This might help...
>> word1: "test"
== "test"
>> type? word1
== string!
>> word2: 'word1 ;this assigns word2 to the word word1 not its value
== word1
>> type? word2
== word!
>> word2
== word1
>> word3: word1 ;word1 is naturally evaluated to "test" then assigned
== "test"
>> type? word3
== string!
>> word3
== "test"
>> word4: :word1 ;this method takes the value of word1 without evaluation.
== "test"
>> type? word4
== string!
>> word1: "TTTTT"
== "TTTTT"
>> word4
== "test"
>> word3
== "test"
>>
Something else you should know...
>> p1: print
** Script Error: print is missing its value argument.
** Where: p1: print
>> p1: :print ;skips evaluation of print, just gets its value.
>> p1 "me"
me
>>
--Ryan
[eric--mccinc--com] wrote:
> I seem to be misunderstanding the use of words in rebol.
> say I had the following code
<<quoted lines omitted: 10>>
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
I am enough of an artist to draw freely upon my imagination.
Imagination is more important than knowledge. Knowledge is
limited. Imagination encircles the world.
-Einstein
[4/7] from: christian::ensel::gmx::de at: 19-Oct-2000 20:06
Hi Eric,
look at the following console session:
>> word1: "initial value"
== "initial value"
>> set 'word1 "new value"
== "new value"
>> word1
== "new value"
>> word2: 'word1
== word1
>> set word2 "even newer value"
== "even newer value"
>> word1
== "even newer value"
The above makes use of the fact that SET expects a LIT-WORD! to determine
which word it should assign the value to.
> If I am completly off the mark on this one let me know.
You're not ;-)
Look at
>> f1: func ['word] [print ["Function was called on word" word]]
>> ; ^^^^^
>> f1 some-word
Function was called on word some-word
>> f1 'some-word
Function was called on word some-word
>> f2: func [word] [print ["Function was called on" word]]
>> ; ^^^^
>> f2 some-word
** Script Error: some-word has no value.
** Where: f2 some-word
>> f2 'some-word
Function was called on word some-word
Regards
Christian
[Christian--Ensel--GMX--De]
[5/7] from: rebol:svendx:dk at: 19-Oct-2000 20:30
Hello [eric--mccinc--com],
You can use get and set:
## word1: "This is a word"
== "This is a word"
## word2: 'word1
== word1
## word2
== word1
## get word2
== "This is a word"
## set word2 "It still is"
== "It still is"
## word1
== "It still is"
(## is my rebol prompt...)
/Thomas
On 19-Oct-00, [eric--mccinc--com] wrote:
[6/7] from: eric:mccinc at: 19-Oct-2000 14:41
Hey larry,
This my be a stupid question but does it work the same way for set?as
in
word1: "Hello World"
word2: 'word1
set word2 "New World"
print world1
>>New world
Thanks
[7/7] from: arolls:bigpond:au at: 27-Oct-2000 20:44
Hi Eric,
>> set :word2 "no it isn't, it's a string"
== "no it isn't, it's a string"
>> get word2
== "no it isn't, it's a string"
Anton.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted