[REBOL] Why is the lit-word! datatype! not working
From: gerardcote:sympatico:ca at: 21-Oct-2005 22:10
Hi List,
As I tried to eliminate the need to use the (:) before function names into Higher Order
Functions I got this more user friendly
version to work for me :
>> my-map: func [f blk /local result] [
[ result: make block! length? blk
[ foreach item blk [
[ append/only result do reduce [:f :item]
[ ]
[ result
[ ]
>> my-map 'first ["ab" "cd" "ef"]
== [#"a" #"c" #"e"]
>>
In fact I never got the final objective of eliminate either the : or ' before function
names - probably because when called the
my-map function calls itself the second item which is another function name. So I realized
I could note go farther into this
simplification but I like better to use a ' than a : as it seems more natural to me to
work with a literal to start with.
Being so I tried to add more validation for parameters f and blk as in f [lit-word!]
and blk [block!]. To my great surprise I
received the following error msg. Can someone help me to better understand how REBOL
can send me this error ?
Why is 'first not considered as a real lit-word! datatype! ?
>> my-map: func [f [lit-word!] blk [block!] /local result] [
[ result: make block! length? blk
[ foreach item blk [
[ append/only result do reduce [:f :item]
[ ]
[ result
[ ]
>> my-map 'first ["ab" "cd" "ef"]
** Script Error: my-map expected f argument of type: lit-word
** Where: halt-view
** Near: my-map 'first ["ab" "cd" "ef"]
>>
Thanks!
Regards,
Gerard