IsHandle


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


You are not allowed to post comments.