File predicat.icn |
General purpose test procedures contributed by various people:
Art Eschenlauer Kevin Wampler Steve Wampler (<i>sbw@tapestry.tucson.az.us</i>)This is one of several files contributing to the lang package. Changes have been made to rationalise the code to use Unicon functions to avoid implementation dependencies.
This file is in the public domain.
This file is part of the lang package.
Source code.Details |
Procedures: |
name of class var and all superclasses or standard
Unicon type if var is not a class |
A version of the type command designed to work on classes. For non class objects it behaves exactly as the standard type() function. For classes it generates the name of the class and the names of all classes that it inherits from
Note: For all entities defined in packages, returns user-level form of name, e.g.: "package::class" instead of the internal form of name, e.g.: "package__class".
We now use the langprocs procedure instead of implementation dependent code. As with isClass(), this can be tricked by evil people.
Object to examinex | -- class to test |
className | -- name of potential ancestor or actual potential ancestor.
For example, instanceof(X,"lang::Object") and
instanceof(X,Object()) are equivalent. |
x if x is an instance of className |
Is className an ancestor of class x? Any class is considered as an ancestor of itself.
var if it's a class |
if var is not a class |
How to tell if something is a class. We now use the langprocs procedure instead of implementation dependent code. This can be tricked, but only by evil people.
Object to examine x if x is a list |
if x is not a list |
Is x a list?
Object to examine x if x is a procedure |
if x is not a procedure |
Is x a procedure?
Object to examine x if x is a record |
if x is not a record |
Is x a record? A class is NOT a record! Use get_type(o) which returns "record" for all not object/class values that are records.
Object to examine x if x is a set |
if x is not a set |
Is x a set?
Object to examine x if x is a table |
if x is not a table |
Is x a table?
Object to examinex | Object to examine
|
s |
x if it's of type s |
if x is not of type s |
Is the type of x s? Works even if s is "class" or "record". Also works if s is an actual class instead of a string, as in:
if istype(x,Object())
Will accept s as "numeric" to check if x is either a real or an integer.
Type to check againstIntended for internal use only. Map "package__object" into "package::object". This is implementation dependent code and at present there is no Unicon function that returns the package information for any defined value. It also checks that the name is not in external format first and if it finds it is then it will return it unchanged. This allows "__" to be used in external names.