Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Help me, Obi Reb Kenobi, you're my only hope!

From: lmecir:mbox:vol:cz at: 28-Aug-2002 17:37

Hi Jason, even Rebol expressions such as: try [print "hello"] or do [print "hello"] or () yield a Rebol value, which, is of type UNSET!. Check: type? try [print "hello"] ; == unset! or probe head insert [] try [print "hello"] ; == [unset] etc. The only trouble with a value of that type is, that you cannot use it in an expression like: a: () , which fires an error. OTOH, you can use UNSET! type value like this: set/any 'a () probe head insert [] () ; == [unset] type? () ; == unset! error? () ; == false unset? () ; == true etc. Generally spoken, if your expression can yield an UNSET! type value, you have to use (set/any 'a ...) instead of (a: ...). The trouble with this approach is, that in the former case you lose the typo protection you normally have. If no Rebol expression was allowed to yield an UNSET! type value, this "problem" wouldn't exist. ----- Original Message ----- From: "Jason Cunliffe" <[jason--cunliffe--verizon--net]> To: <[rebol-list--rebol--com]> Sent: Wednesday, August 28, 2002 8:12 AM Subject: [REBOL] Re: Help me, Obi Reb Kenobi, you're my only hope! hmmm.. I also be glad if someone can explain this issue well
>> Fred: Try ["hello"]
== "hello"
>> fred
== "hello"
>> Fred: Try [print "hello"]
hello ** Script Error: Fred needs a value ** Near: Fred: Try [print "hello"]
>> >> ? try
USAGE: TRY block DESCRIPTION: Tries to DO a block and returns its value or an error. TRY is a native value. ARGUMENTS: block -- (Type: block)
>> do [print "hello"]
>> fred: do [print "hello"]
hello ** Script Error: fred needs a value ** Near: fred: do [print "hello"]
>> fred: do ["hello"]
== "hello"
Looks like REBOL is being very consistent. So RebGurus, how do you interpret "returns its value" in this context? Which Rebol statements have value? thanks ./Jason