tags:

views:

53

answers:

2

Given a list:

a: [1 2 3 4 5]

Why is it clear a to clear the list and unset 'a to unset it? I would have expected both clear and unset to consistently take either a or 'a as their arguments.

+2  A: 

Clear removes entries from the block referenced by the word a:

a: [1 2 3 4 5]
length? a
== 5
clear a
length? a
== 0

Unset removes the word a itself:

a: [1 2 3 4 5]
length? a
== 5
unset 'a
length? a
** Script Error: a has no value
** Near: length? a
Sunanda
unset has to take a word ... if you wanted to unset a function, you couldn't without it executing.
Graham Chiu
A: 

UNSET is an operation that takes a value of type WORD! and CLEAR is an operation that takes a value of type SERIES! Note that multiple words can point to the same SERIES! value...

>> a: [m a t t]
== [m a t t]

>> b: a
== [m a t t]

>> clear a
== []

>> b
== []

Since passing a WORD! into a series operation has no meaning at present, it's technically possible that CLEAR could elect to recognize when you passed it a WORD! value, and do something special in that case (for instance, look up the value associated with that word--if any--and erase its values). But "implicitly indirect a word if there is no other meaning" isn't a particularly nice invariant, and you won't find it in operations like FIRST or FIND etc.

The reverse case... to have unset QUOTE its argument implicitly... would be technically possible. But if it did, how would you handle the case when the WORD! to unset was stored in another WORD?

>> c: [m a t t]
== [m a t t]

>> d: 'c
== c

>> unset d

>> c
** Script error: c has no value

>> d
== c

>> unset 'd

>> d
** Script error: d has no value
Hostile Fork