[REBOL] Re: Submitted, for your approval.
From: carl:cybercraft at: 27-May-2002 21:35
On 27-May-02, Ed Dana wrote:
> Greetings all,
> Attached is a small game I created in my continuing effort to
> understand REBOL. It is another guessing game, slightly more
> sophisticated than the one I submitted previously.
> Please look it over and feel free to criticize, but do be gentle, as
> this is my second attempt at a REBOL program. ;)
Hi Ed,
It works fine, though I was a bit confused by the Matched and Placed
numbering to begin with, not realizing that once something was placed
it was no longer recorded as matched. "Misplaced" might've been a
better term. (;
As to your code: Well you've got me wondering whether having a
function call it's own refinements like that instead of having
seperate functions for those routines is a good or bad thing... I
think it probably is bad, (mainly due to a performance issue with the
amount of code you have to get through to get to the last "if
whatever..."), but as you've found out, it does work. Note however
that it only works because the words you create in the function are
global, not local. If you'd tried to make Symbol_Set local by
having...
/local Symbol_Set
in the function's first block you'd get an error when calling the
function with any refinement other than /begin. With REBOL
functions, words defined in the body of the function are made global
by default, not local. This is because "it's better for beginners"
apparently. (:
An alternative approach to using refinements would've been to have
them as functions within your function. ie, just change...
If Begin [
Symbol_Set: [ "~" "!" "@" "#" "$" "%" "&" "*" ]
Random/seed Now
]
to...
Begin: does [
Symbol_Set: [ "~" "!" "@" "#" "$" "%" "&" "*" ]
Random/seed Now
]
and you can then call that with just "Begin" instead of
Symbols/Begin
. ('does is for functions without any arguments.)
Otherwise though, you're learning fast! It's good and tidy code on
the whole.
--
Carl Read