Prefix colon question
[1/5] from: tim:johnsons-web at: 1-Jun-2002 11:47
Hello All:
<blush>I'm embarassed to have to admit that
I don't fully understand the use of the prefix colon</blush.
I use it only for referencing a member of a series
as in my-series/:indx
I see it used in many other ways, but don't fully comprehend
the differences between (for instance) my-variable and :my-variable
Could anyone help to enlighten me here?
TIA
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com
[2/5] from: tim:johnsons-web at: 1-Jun-2002 13:03
* Jason Cunliffe <[jason--cunliffe--verizon--net]> [020601 12:30]:
> > Could anyone help to enlighten me here?
>
> It's the same as "get"
> I that the key is that everything in REBOL is a value..
> I can't give you deep golden answers but try this:
[....]
Thanks Jason: I understand that fully. Let me 'probe deeper:
what's the difference between:
test: func[a b /local c][c: a + b c]
and
test: func[a b /local c][c: a + b :c]
And perhaps there isn't any difference in my example
but I think I do see :my-word at the 'return point in many
functions
Thanks Again!
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com
[3/5] from: jason:cunliffe:verizon at: 1-Jun-2002 16:23
> Could anyone help to enlighten me here?
It's the same as "get"
I that the key is that everything in REBOL is a value..
I can't give you deep golden answers but try this:
>> pwd: :what-dir
>> pwd
== %/C/rebol/view/
>> source pwd
pwd: func [
"Prints the active directory path"
][
system/script/path
]
now clear it and try again using get
>> pwd: none
== none
>> pwd: get 'what-dir
>> source pwd
pwd: func [
"Prints the active directory path"
][
system/script/path
]
>> ? get
USAGE:
GET word /any
DESCRIPTION:
Gets the value of a word.
GET is a native value.
ARGUMENTS:
word -- Word to get (Type: any-word)
REFINEMENTS:
/any -- Allows any type of value, even unset.
>> what-dir
== %/C/rebol/view/
>> source what-dir
what-dir: func [
"Prints the active directory path"
][
system/script/path
]
./Jason
[4/5] from: al:bri:xtra at: 2-Jun-2002 10:44
The difference between:
c
and:
:c
is that ":c" doesn't evaluate the value of "c".
>> o: make object! [m: 123]
>> c: first [o/m]
== o/m
>> probe :c
o/m
== o/m
>> probe c
123
== 123
>> f: func [arg] [print ["I'm F!" arg "I've been evaluated!"]]
>> f 123
I'm F! 123 I've been evaluated!
>> probe :f
func [arg][print ["I'm F!" arg "I've been evaluated!"]]
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[5/5] from: nitsch-lists:netcologne at: 2-Jun-2002 4:44
Am Samstag, 1. Juni 2002 23:03 schrieb Tim Johnson:
> * Jason Cunliffe <[jason--cunliffe--verizon--net]> [020601 12:30]:
> > > Could anyone help to enlighten me here?
<<quoted lines omitted: 13>>
>> f: func[]["something"]
>> probe f
something
== "something"
>> probe :f
func []["something"]
for most datatypes [f] and [:f] are the same, but for datatypes
which get executed [f] executes and [:f] returns.
so if you move functions or pathes or parens,
pass them with [:f].
(with new betas only remaining "hot" datatype is function afaik)
> Thanks Again!
-volker
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted