Words with no value error
[1/9] from: the::optimizer::tiscali::it at: 8-Jan-2004 18:03
Hi all,
I have menaged to read all the over 400 messages from this list sent
during last month... :P
I have a question about the " Script Error: xxx has no value" problem.
I have seen that there's no way to trap such an error, which is not a
syntax one.
'value? does not work, nor does 'error?.
But why 'try and 'throw-on-error do not as well? Aren't they thought to
trap this kind of dynamic errors?
It appears to be more a bug than a wanted feature.
Notice that a word can come as a parameter of a function and 'get can be
used on it. But there's no way to catch such an error, halting the script
execution. So using the features Rebol provides (such as data = code) can
result in a lethal error and cannot be used when the input has not been
previously checked (if such a check is ever possible).
Hope this is going to be fixed soon.
Mauro<
[2/9] from: SunandaDH:aol at: 8-Jan-2004 12:19
Mauro:
> I have a question about the " Script Error: xxx has no value" problem.
>
> I have seen that there's no way to trap such an error, which is not a
> syntax one.
>
> 'value? does not work, nor does 'error?.
Maybe I misunderstand your question. But I can, and regularly do, capture
such errors:
>> xxx
** Script Error: xxx has no value
** Near: xxx
>> if error? capture-error: try [xxx] [print mold disarm capture-error]
make object! [
code: 300
type: 'script
id: 'no-value
arg1: 'xxx
arg2: none
arg3: none
near: [xxx]
where: none
]
Sunanda<
[3/9] from: andreas:bolka:gmx at: 8-Jan-2004 18:45
Thursday, January 8, 2004, 6:03:04 PM, M&F wrote:
> I have a question about the " Script Error: xxx has no value"
> problem.
> I have seen that there's no way to trap such an error, which is not
> a syntax one.
if error? try [ an-unset-value ] [ ... ]
--
Best regards,
Andreas
[4/9] from: tim:johnsons-web at: 8-Jan-2004 8:54
* M&F <[the--optimizer--tiscali--it]> [040108 08:26]:
> Hi all,
> I have menaged to read all the over 400 messages from this list sent
<<quoted lines omitted: 3>>
> syntax one.
> 'value? does not work, nor does 'error?.
Hi Mauro:
Try this little console session to get a feel for rebol words
and values.
Then read my comments at the end.
>> t: attempt[x]
== none
>> y: 2
== 2
>> t: attempt[y]
== 2
>> value? 'x
== false
>> print 'x
x
>> print x
** Script Error: x has no value
** Near: print x
Think of a rebol word as a white-space delimited
string. a rebol word may or may not have a value.
But it always has a spelling.
If you've done anything with LISP or scheme, this
is the inspiration for rebol....
Testing for a value requires a single quote
as in value? 'x
as opposed to value? x
Using 'attempt is guaranteed to return a 'none if
the word has not value.
There is a tutorial on rebol evaluation techniques
using my 'fetch function (somewhere) you might
want to dig into that some time.
HTH
tim
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com<
[5/9] from: the:optimizer:tiscali:it at: 9-Jan-2004 2:31
On Thu, 8 Jan 2004 12:19:19 EST, <[SunandaDH--aol--com]> wrote:
>> I have a question about the " Script Error: xxx has no value" problem.
>>
<<quoted lines omitted: 19>>
> ]
> Sunanda
Sh*t... should have a better look at TFM! 574 pages and I still can't
understand the basis of the language!! 8(
I'm finding Rebol more challeging than any ASM I've tried... here usual
programming logic seems to be messed up...
I'll try later with my head shakered... next I'll knock it against the
edge of the desktop... and if still does not work I'll start using heavy
drugs... maybe that way everything will be clearer...
Thanks everyone.
Mauro<
[6/9] from: antonr:iinet:au at: 9-Jan-2004 13:18
Yes, as Andreas shows, there problem is when the
try block returns an unset! value. eg:
>> if error? err: try [print "hi"][]
hi
** Script Error: err needs a value
** Near: if error? err: try [print "hi"]
Why did that happen?
try does the code block, and returns the last value, or
an armed error! object if there was an error.
But print doesn't return a value, so unset! is returned
(this is not an error).
err: is a set word and when it is done it expects a value.
unset! isn't good enough to be considered a value, so you
get the error message above.
The solution most of us have settled on is to use set/any, like this:
>> if error? set/any 'err try [print "hi"][print mold disarm err]
hi
== none
Using set/any allows the word 'err to also be set to an unset! as well
as all the usual values.
Anton.
[7/9] from: tim:johnsons-web at: 8-Jan-2004 17:34
* M&F <[the--optimizer--tiscali--it]> [040108 16:50]:
> On Thu, 8 Jan 2004 12:19:19 EST, <[SunandaDH--aol--com]> wrote:
> >> I have a question about the " Script Error: xxx has no value" problem.
<<quoted lines omitted: 29>>
> I'm finding Rebol more challeging than any ASM I've tried... here usual
> programming logic seems to be messed up...
Mauro:
1)When in rebol, think 'rebol', don't think 'Assembler'
2)Learn rebol evaluation. And remember that
in rebol (as in Assembler),
data and code are the same.
Best of Luck and keep commin' back.
Tim (old assembler programmer)
> I'll try later with my head shakered... next I'll knock it against the
> edge of the desktop... and if still does not work I'll start using heavy
<<quoted lines omitted: 4>>
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com<
[8/9] from: andreas:bolka:gmx at: 9-Jan-2004 4:06
Friday, January 9, 2004, 3:18:05 AM, Anton wrote:
> Yes, as Andreas shows, there problem is when the try block returns
> an unset! value. eg:
Thanks, Anton, for making something useful out of my being
unconcentrated :)
As a sidenote, anybody ever compiled a list of all native!'s that
return unset! ?
--
Best regards,
Andreas
[9/9] from: SunandaDH:aol at: 9-Jan-2004 7:27
Hi Mauro:
> Sh*t... should have a better look at TFM! 574 pages and I still can't
> understand the basis of the language!! 8(
<<quoted lines omitted: 3>>
> edge of the desktop... and if still does not work I'll start using heavy
> drugs... maybe that way everything will be clearer...
With REBOL, it's red-pill time :-)
Sunanda<
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted