[REBOL] Re: local vars in functions
From: lmecir:mbox:vol:cz at: 1-May-2002 15:16
Hi Romano,
you got me again! My models are unable to demonstrate the behaviour your
code relies on:
<Romano>
...
not so readable, i must admit (and 'object could be replaced by 'set-words
to
make it more unreadable):
blank-object: func [
{make a blank object from a block of set-words}
blk [block!]
] [
unset in blk: context compose [exit (blk)] 'self
blk
]
</Romano>
:-o I would have guessed, that the only way how to do that would be:
blank-object: func [
{make a blank object}
blk [block!]
] [
unset in blk: context compose [return self (blk)] 'self
blk
]
It is a mistery for me, why exit works in this case.
> unbound?: function [
> {determines, if a word is unbound}
> word [any-word!]
> ] [err] [
> found? all [
> error? err: try [any-type? get/any :word]
> err: disarm err
> equal? err/id 'not-defined
> ]
> ]
<Romano>
If
equal? err/id 'not-defined
is false, the function returns false, but the status of the word is unknown,
so i think it should be better to fire an error!
---
Ciao
Romano
</Romano>
My goal was to find out, whether the examined word is unbound or not. I am
pretty sure, that the word in question is unbound only if the error id is
'not-defined. In the above case the source of the error isn't the GET/ANY
expression, but the ANY-TYPE? function, which has nothing to do with the
binding of the examined word. (the examined word is clearly bound to the
created object)
Nevertheless, it is a shocking experience, that there is a Rebol value which
isn't acceptable for the ANY-TYPE? function. I suggest you to summarize your
findings and send them all to feedback.