| Did you know ... | Search Documentation: |
| Get methods |
<-check
method is the normal way to activate a type. The first argument is the
object to be checked. The second is the receiver that requests the
conversion. The latter is currently used only for the
type<->kind
member.
Types are normally referred to by their type<-name
rather than by their reference. For this reason type checking and
conversion is also accessible through pce<-convert.
The following two lines are identical:
?- get(@pce, convert, '34', int, Int). ?- get(type(int), check, '34', Int).
First, type->validate
is activated. If this fails, type<-translate
is activated and the result thereof is returned.
<-convert -type ->validate <-translate -supers
<Type> ::= <KindType>
| <SingleType> '...' % Methods: Varargs
<KindType> ::= 'alien:'<C-type> % Alien (C) types
| 'member:'<Single> % Members
<Single> ::= <PrimType>
| <Single>'|'<Single> % Disjunction
| '['Single']' % May be @default
| <Single>'*' % May be @nil
<PrimType> ::= <PredefinedType> % any defined type
| {<Name>',' ...} % name_of
| <int>'..'<int> % integer range
| <real>'..'<real> % real range
| <ClassName>
Below are some examples:
point Instance of class point or a subclass
int integer
[name] A name or @default
graphical* A graphical object or @nil
int|point integer or point
{left,right} either the name 'left' or 'right'
|function
Accepts a name or a function
object.
<-convert ->initialise
?- get(@pce, convert, '{left,center,right}', type, X),
?- get(X, copy, format_name, _).
Creates a type format_name that accepts the names’left’,’center’or’right’.
->initialise
translate(Type type, Any value, Object context)
{ Activate translate_function.
IF successful, return the translated value;
ELSE try super-types until one succeeds and return the value
}
<-check
because the argument may not be of the requested type.->validate <-check -translate_function<-completions
to perform automatic completion.
Currently this method takes care of:
<-kind
= name_of types ({name1,name2})<-kind
= int_range if the range entails at most 10 integers<-kind
= value<-supers