RAMBO #3652 unset?
[1/9] from: apwing:zonnet:nl at: 22-Mar-2005 12:06
Hi Gabriele,
thanks for your explanation in RAMBO.
Still I have a few remarks / questions.
#1. it seems very odd to me that unset and unset? are in fact unrelated!
Unset causes a variable to have it's value removed.
Unset? checks for datatype unset!
#2. Is () the only "thing" with datatype unset! ?
If not, what other "things" have this value ?
Could you give one or more practical examples of the use of
unset! and unset? ?
Kind regards,
Arie
[2/9] from: lmecir::mbox::vol::cz at: 22-Mar-2005 15:05
Hi Arie,
>Hi Gabriele,
>
>thanks for your explanation in RAMBO.
>
>Still I have a few remarks / questions.
>
>#1. it seems very odd to me that unset and unset? are in fact unrelated!
> Unset causes a variable to have it's value removed.
> Unset? checks for datatype unset!
>
you are right:
unset? is related to unset! exactly like integer? relates to integer! etc.
>#2. Is () the only "thing" with datatype unset! ?
> If not, what other "things" have this value ?
> Could you give one or more practical examples of the use of
>unset! and unset? ?
>
check the following expressions:
do []
print ""
prin ""
do does [exit]
forever [break]
get/any 'uninitialized-variable
A "practical example" - a function accepting an optional integer argument:
f: func [argument [integer! unset!]] [
print ["Argument:" either value? 'argument [argument] ["not
supplied"]]
]
f 12
f
-Ladislav
[3/9] from: rotenca::telvia::it at: 22-Mar-2005 15:29
Ladislav Mecir wrote:
>check the following expressions:
> do []
<<quoted lines omitted: 3>>
> forever [break]
> get/any 'uninitialized-variable
other examples:
unset? unset 'a
unset? set/any 'a unset 'b
unset? do does [return]
unset? catch[throw]
--
Ciao
Romano Paolo Tenca
[4/9] from: apwing:zonnet:nl at: 22-Mar-2005 16:22
Hi Ladislav / Romano,
in order to get a grip I played around with your examples, but I don't
understand the following:
why give the following 2 cases different results?
1 >>unset 'var
>>unset? 'var
== false
2 >>unset? unset 'var
== true
The only thing I can think of is that unset! is not a datatype of the
variable being unset.
E.g. after unset 'x x would not have a datatype of unset! (which I thought
was true).
Instead unset! would just be the returned value of unset itself only.
Thanks!
Arie
P.S. Ladislav the example of function f is very useful!
Romano Paolo Tenca wrote: Ladislav Mecir wrote: check the following
expressions: do [] print "" prin "" do does [exit] forever [break] get/any
'uninitialized-variable other examples: unset? unset 'a unset? set/any 'a
unset 'b unset? do does [return] unset? catch[throw]
[5/9] from: rotenca::telvia::it at: 22-Mar-2005 19:07
Arie van Wingerden wrote:
>Hi Ladislav / Romano,
>in order to get a grip I played around with your examples, but I don't
<<quoted lines omitted: 10>>
>was true).
>Instead unset! would just be the returned value of unset itself only.
1a)
unset 'var
what happens?
- the lit-word! <var> is evaluated and become the word <var>
- unset receives the word <var> and unsets the value of the word <var>
1b) unset? 'var
what happens?
- the lit-word! <var> is evaluated and become the word <var>
- unset? receives the word <var> and answers:
"false: the value <var> is not an unset! value (it is a word!)"
- you can test this with:
word? 'var ; == true
2) unset? unset 'var
what happens?
- the lit-word! <var> is evaluated and become the word <var>
- unset receives the word <var> and unsets the value of the word <var>
- unset returns unset!
- unset? receives the values unset! and answers "true: the value
<unset!> is an unset! value"
- now you can test the value of <var> with one of :
value? 'var ; == false
which is the opposite of::
unset? get/any 'var ;==false
The unset/unset?/value? stuff is a little strange at the beginning, but
when you get the whole frame, all becomes clear.
--
Ciao
Romano Paolo Tenca
[6/9] from: rotenca::telvia::it at: 22-Mar-2005 19:18
Romano Paolo Tenca wrote:
> which is the opposite of::
> unset? get/any 'var ;==false
>
unset? get/any 'var ;==true
(typo error)
--
Ciao
Romano Paolo Tenca
[7/9] from: apwing::zonnet::nl at: 22-Mar-2005 20:25
Hi Romano,
this was *very* helpful for me!
And I guess there are others out there being happy with your explanation.
Thanks again,
Arie
Romano Paolo Tenca wrote:
[8/9] from: lmecir:mbox:vol:cz at: 23-Mar-2005 12:30
Arie van Wingerden napsal(a):
>Hi Ladislav / Romano,
>in order to get a grip I played around with your examples, but I don't
<<quoted lines omitted: 12>>
>Thanks!
> Arie
a little note:
unset? ...
is equivalent to:
unset! = type? ...
while
type? 'variable
is always equal to word!
HTH
[9/9] from: apwing::zonnet::nl at: 23-Mar-2005 18:07
Thanks Ladislav!
I appreciate all the help
Arie
Ladislav Mecir wrote:
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted