[REBOL] Best way to alias words
From: greggirwin::mindspring::com at: 9-Nov-2001 14:44
This is two part question:
Technically, is there a "best" way to define word aliases (the main
consideration being efficiency)?
>From a design perspective what's best for clarity, and ease of maintenance?
This is highly subjective of course.
The candiates are:
;-- Multiple assignment
obj: context [
?: help: does [
print "Help...coming soon"
]
]
;-- Explicit value setting
obj: context [
?: does [
print "Help...coming soon"
]
help: :?
]
;-- Using 'alias (can be used before or after routine definition)
obj: context [
alias '? "help"
?: does [
print "Help...coming soon"
]
]
The last alternative makes it *very* clear what your intent is, and may also
be the most efficient, but I hit a little snag with my example and I'm not
sure why:
** Script Error: Alias word is already in use: help
** Where: context
** Near: alias '? "help"
I haven't figured out what the rules are that cause it to fail. "help" and
x
fail, but "xx" and "help-me" work just fine. Does anyone know if alias
checks against system words for conflicts, not taking the context into
account?
Let me know what you think, or if you're totally against alias'ing in any
form.
Thanks!
--Gregg