I was trying to use the ( ') single quote mark in front of the parameter
of a function to prevent evaluation, mainly so I could leave off
quote marks and even the single tick when calling from the command line.
e.g.
get-person: func [
'person [word!]
][
case: [[word!]c
I 1
you 2
he 3
she 3
we 1
yall 2
they 3
]
return select case person
]
so far so good,
I can type at the prompt:
get-person you
and it will return 2.
I already found out that with non-integers in the case statement
you have to use
return get select case person,
which makes sense.
note that without the ' in front of the parameter, I would have to type
get-person 'you
or even worse, using strings, I would have to type
get-person "you"
which has even more syntax-overhead.
I know I could also surround the paramlist with brackets and make it a block:
get-person [you and other unevalueated words here]
which is ok, but having to even type the brackets is no fun.
If there were lots of params, that would be ok,
but for just one or two params, it's just overhead having the brackets
well, all was fine until I decided to call get-person from inside another
function
make-answers: func [
'person [word!]
/local
o
][
o: make object! [
number?: get-person person
]
; actually I put other stuff in the object, too, but I am trying to focus on the
problem here
return o
]
This it turns out won't work, and I can kind of see why.
it passes 'person in instead of the actual value of person,
which might be 'you or something like that.
The ONLY way I figured out how to do it was this:
number?: do reduce [:get-person person]
Is that the only way? I was hoping there was something simpler and shorter,
as I might have to do that a lot.
I know some of you guys are very sharp and have been down this road before.
Are there in-built functions to do this that I just don't remember or didn't
find,
or is there a function I could write that would let me do funcitons like that,
is there something that combines do and reduce, etc. etc.
Is there a better way to throw words around without a lot of extra syntax
involved?
Is this where one should try to use a dialect or is that even more trouble than
it's worth for something like this?
Obviously if I was willing to enter all my words
with ' in front of them in a statement then I wouldn't be stuck now, but I am
trying
to see how much juice I can get out of Rebol. It has a lot of cool features
that
most other languages lack.
Thanks, folks!
-galt