Difference between revisions of "IsHandle"
m (→See Also) |
|||
Line 1: | Line 1: | ||
[[Category:Data Type Functions]] | [[Category:Data Type Functions]] | ||
− | |||
− | |||
− | |||
+ | == IsHandle(X'', local'') == | ||
[[IsHandle]](X) tests whether the value in «X» is a [[handle]]. When «X» is array-valued, it tests whether each cell of the array contains a handle. | [[IsHandle]](X) tests whether the value in «X» is a [[handle]]. When «X» is array-valued, it tests whether each cell of the array contains a handle. | ||
− | [[IsHandle]](X,local:true) tests whether a local variable «X» contains a [[handle]]. This form doesn't resolve «X» to its value, and really the only way to tell whether a local variable is acting as an alias of another object. When «X» is something other than the name of a local variable, the optional | + | [[IsHandle]](X, local: true) tests whether a local variable «X» contains a [[handle]]. This form doesn't resolve «X» to its value, and really the only way to tell whether a local variable is acting as an alias of another object. When «X» is something other than the name of a local variable, the optional «local» parameter has no effect. |
− | |||
− | |||
+ | == Library == | ||
Special | Special | ||
− | = Examples = | + | == Examples == |
− | |||
For the examples, assume these global variables are defined as follows: | For the examples, assume these global variables are defined as follows: | ||
+ | :<code>Index I := [1, 2, 3, 4]</code> | ||
+ | :<code>Variable hI := Handle(I)</code> | ||
+ | :<code>Variable B := Table(I)(0, Null, hI, Handle(hI))</code> | ||
− | + | :<code>IsHandle(I) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>IsHandle(hI) → 1</code> | |
− | + | :<code>IsHandle(B) → [0, 0, 1, 1] { ''Indexed by I; local: true has no effect when «X» is not a local variable'' }</code> | |
− | + | :<code>IsHandle(I, local: true) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>IsHandle(hI, local: true) → 1</code> | |
− | + | :<code>IsHandle(B, local: true) → [0, 0, 1, 1] { ''Indexed by I'' }</code> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | :<code>Var x := I Do IsHandle(x) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>Var x := I Do IsHandle(x, local: true) → 0</code> | |
− | + | :<code>Var x := Handle(I) Do IsHandle(x) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>Var x := Handle(I) Do IsHandle(x, local: true) → 1</code> | |
− | + | :<code>Var x := hI Do IsHandle(x) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>Var x := hI Do IsHandle(x, local: true) → 1</code> | |
− | + | :<code>Var x := B Do IsHandle(x) → [0, 0, 1, 1] { ''Indexed by I'' }</code> | |
− | + | :<code>Var x := B Do IsHandle(x, local: true) → 0</code> | |
− | + | :<code>LocalAlias x := I Do IsHandle(x) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>LocalAlias x := I Do IsHandle(x, local: true) → 0</code> | |
− | + | :<code>LocalAlias x := Handle(I) Do IsHandle(x) → [0, 0, 0, 0] { ''Indexed by I'' } </code> | |
− | + | :<code>LocalAlias x := Handle(I) Do IsHandle(x, local: true) → 1</code> | |
− | + | :<code>LocalAlias x := hI Do IsHandle(x) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>LocalAlias x := hI Do IsHandle(x, local: true) → 1</code> | |
− | + | :<code>LocalAlias x := B Do IsHandle(x) → [0, 0, 1, 1] { ''Indexed by I'' }</code> | |
− | + | :<code>LocalAlias x := B Do IsHandle(x, local: true) → 0</code> | |
− | + | :<code>MetaVar x := I Do IsHandle(x) → [0, 0, 0, 0] { ''Indexed by I'' }</code> | |
− | + | :<code>MetaVar x := I Do IsHandle(x, local: true) → 0</code> | |
− | + | :<code>MetaVar x := Handle(I) Do IsHandle(x) → 1</code> | |
− | + | :<code>MetaVar x := Handle(I) Do IsHandle(x, local: true) → 1</code> | |
+ | :<code>MetaVar x := hI Do IsHandle(x) → 1</code> | ||
+ | :<code>MetaVar x := hI Do IsHandle(x, local: true) → 1</code> | ||
+ | :<code>MetaVar x := B Do IsHandle(x) → [0, 0, 1, 1] { ''Indexed by I'' }</code> | ||
+ | :<code>MetaVar x := B Do IsHandle(x, local: true) → 0</code> | ||
− | + | :<code>Index J := 1..5 Do IsHandle(J) → [0, 0, 0, 0, 0] { ''Indexed by J'' }</code> | |
− | + | :<code>Index J := 1..5 Do IsHandle(J, local: true) → 1</code> | |
+ | :<code>MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J) → [0, 0, 1, 1] { ''Indexed by J'' }</code> | ||
+ | :<code>MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J, local: true) → 1</code> | ||
− | = | + | :<code>Function F(X:Variable) := IsHandle(X, local: true) → 1</code> {always} |
+ | :<code>Function F(X:Object) := IsHandle(X, local: true) → 1</code> {always} | ||
+ | == See Also == | ||
* [[Data Type Functions]] | * [[Data Type Functions]] | ||
− | * [[Var..Do]] | + | * [[Var..Do]] |
+ | * [[MetaVar..Do]] | ||
+ | * [[LocalAlias..Do]] | ||
* [[Handle Functions]] | * [[Handle Functions]] |
Revision as of 03:07, 20 January 2016
IsHandle(X, local)
IsHandle(X) tests whether the value in «X» is a handle. When «X» is array-valued, it tests whether each cell of the array contains a handle.
IsHandle(X, local: true) tests whether a local variable «X» contains a handle. This form doesn't resolve «X» to its value, and really the only way to tell whether a local variable is acting as an alias of another object. When «X» is something other than the name of a local variable, the optional «local» parameter has no effect.
Library
Special
Examples
For the examples, assume these global variables are defined as follows:
Index I := [1, 2, 3, 4]
Variable hI := Handle(I)
Variable B := Table(I)(0, Null, hI, Handle(hI))
IsHandle(I) → [0, 0, 0, 0] { Indexed by I }
IsHandle(hI) → 1
IsHandle(B) → [0, 0, 1, 1] { Indexed by I; local: true has no effect when «X» is not a local variable }
IsHandle(I, local: true) → [0, 0, 0, 0] { Indexed by I }
IsHandle(hI, local: true) → 1
IsHandle(B, local: true) → [0, 0, 1, 1] { Indexed by I }
Var x := I Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
Var x := I Do IsHandle(x, local: true) → 0
Var x := Handle(I) Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
Var x := Handle(I) Do IsHandle(x, local: true) → 1
Var x := hI Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
Var x := hI Do IsHandle(x, local: true) → 1
Var x := B Do IsHandle(x) → [0, 0, 1, 1] { Indexed by I }
Var x := B Do IsHandle(x, local: true) → 0
LocalAlias x := I Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
LocalAlias x := I Do IsHandle(x, local: true) → 0
LocalAlias x := Handle(I) Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
LocalAlias x := Handle(I) Do IsHandle(x, local: true) → 1
LocalAlias x := hI Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
LocalAlias x := hI Do IsHandle(x, local: true) → 1
LocalAlias x := B Do IsHandle(x) → [0, 0, 1, 1] { Indexed by I }
LocalAlias x := B Do IsHandle(x, local: true) → 0
MetaVar x := I Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
MetaVar x := I Do IsHandle(x, local: true) → 0
MetaVar x := Handle(I) Do IsHandle(x) → 1
MetaVar x := Handle(I) Do IsHandle(x, local: true) → 1
MetaVar x := hI Do IsHandle(x) → 1
MetaVar x := hI Do IsHandle(x, local: true) → 1
MetaVar x := B Do IsHandle(x) → [0, 0, 1, 1] { Indexed by I }
MetaVar x := B Do IsHandle(x, local: true) → 0
Index J := 1..5 Do IsHandle(J) → [0, 0, 0, 0, 0] { Indexed by J }
Index J := 1..5 Do IsHandle(J, local: true) → 1
MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J) → [0, 0, 1, 1] { Indexed by J }
MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J, local: true) → 1
Function F(X:Variable) := IsHandle(X, local: true) → 1
{always}Function F(X:Object) := IsHandle(X, local: true) → 1
{always}
See Also
Comments
Enable comment auto-refresher