[REBOL] Re: Don't understand "try" and "disarm"
From: tim-johnsons:web at: 15-Mar-2006 7:42
* Gabriele Santilli <gabriele-colellachiara.com> [060315 02:54]:
> Hi Steven,
> On Tuesday, March 14, 2006, 5:46:39 PM, you wrote:
> SW> This "set-word" concept is a bit confusing, but I am going to wait with
> SW> my criticism of the REBOL documentation until I have re-read it, plus
> SW> the two books I have purchased. Then I'll complain.
> Try something like this at the console:
> word: write %file "something"
> word: print "hello"
A rebol 'word is a symbol. It may or it may not have a value, if it
has no value it is considered unset.
Lisp programmers understand this instinctively, but for the rest of
us, it is best to take it one step at a time.
It took me a long time to understand coming from C/C++
When you follow Gabrielle's instructions, you will get an error, but
do not be dismayed. Here's a copy of an annotated console session for
you which expands a bit:
>> word: print "hello"
hello ;; print sends "hello" to stdout
** Script Error: word needs a value
** Near: word: print "hello"
;; but you get an error, because the set-word word: expects a return
;; value but print does not return any value
;; now let us use the unset? predicate to test for a return value
>> unset? print "hello"
>> help unset?
Returns TRUE for unset values.
UNSET? is an action value.
value -- (Type: any-type)
Now try it youself.
I could say more, like how helpful this concept can be, but let's take
it one step at a time.
Once that sinks in a bit, we can show you some really cool tricks with
words that may make you never want to use another language again.
Or maybe lisp. :-)
Tim Johnson <tim-johnsons-web.com>