New built-in flags, predicates, and functions proposal

pmoura@di.ubi.pt

November 17, 2008

This proposal is written as an extension to the ISO/IEC 13211-1 Prolog standard, adopting a similar structure. Specifically, this proposal either adds new sections and clauses to, or modifies the reading of existing clauses on ISO/IEC 13211-1.

This draft proposal may contain in several places informative text,
type-set in *italics*. Such informative text is used for
editorial comments deemed useful during the development of this draft
and may not be included in the final version.

- Bart Demoen (Belgium)
- Jan Wielemaker, (Netherlands)
- Joachim Schimpf (UK)
- Jonathan Hodgson (USA)
- Katsuhiko Nakamura (Japan)
- Klaus Daessler (Germany)
- Mary Kroening (USA)
- Michael Covington (USA)

1 SCOPE 2

- Neng-Fu Zhou (USA)
- Paulo Moura (Portugal)
- Pierre Deransart (France)
- Péter Szabó (Hungary)
- Péter Szeredi (Hungary)
- Rémy Haemmerlé (France)
- Richard O'Keefe (NZ)
- Roberto Bagnara (Italy)
- Roger Scowen (UK)
- Ulrich Neumerkel (Austria)

- a) A set of flags allowing a programmer to query a system about the floating-point arithmetic implementation and to declare the default encoding for Prolog text
- b) Commonly used term testing predicates already available in most Prolog systems that are missing from ISO/IEC 13211-1:1995
- c) Commonly used meta-predicates which should be available as built-in predicates in order to provide adequate performance
- d) A set of built-in predicates for list processing, providing functionality similar to the atomic processing built-in predicates present on ISO/IEC 13211-1:1995
- e) Commonly used evaluable functors that are missing from ISO/IEC 13211-1:1995

NOTE — This part of ISO/IEC 13211 will eventually merge with ISO/IEC 13211-1:1995 resulting in a new version of the Part 1 standard.

7 LANGUAGE CONCEPTS AND SEMANTICS 3

Priority Specifier Operators(s) 500 yfx + - /\ \/ ><

Priority Specifier Operators(s) 200 fy + - \

`P`

is a pair if it is a compound term ```
'-'(Key,
Value)
```

where `Key`

and `Value`

are terms.
NOTE — In Prolog text and this part of ISO/IEC
13211 a pair`'-'(Key, Value)`

is normally written
as `Key-Value`

or `(Key)-(Value)`

depending on
whether or not `Key`

and `Value`

are operators.

`encoding(E)`

specifies that the Prolog text
being prepared for execution uses the encoding `E`

. When
used, this directive shall be the first term, on the first line, in a
Prolog text with no extra layout characters (6.5.4) before
the `:-/1`

directive operator. Moreover, a single layout
character shall be used between the directive operator and the
directive functor. No layout characters or comments shall appear
between the directive opening and closing parenthesis.
Three streams are predefined and open during the execution of every
goal: the standard input stream has the alias `user_input`

,
the standard output stream has the alias `user_output`

, and
the standard error output stream has the
alias `user_error`

.

7 LANGUAGE CONCEPTS AND SEMANTICS 4

NOTES

3 Prolog implementation on systems that do not support an error
output stream shall redirect output to the standard output stream.

`bom(Bool)`

— If `Bool`

(7.1.4.2) is
true then a Unicode encoding *Byte Order Mark* shall be written
when opening a text stream for writing in mode `write`

or
is probed for when opening the text stream for reading. This option
shall be ignored when opening a stream in
mode `append`

. If `Bool`

is `false`

then a Unicode encoding *Byte Order Mark* shall not be written
when opening the text stream for writing.

When no `bom(Bool)`

stream-option is specified, the
default value shall be `true`

when the text stream is
opened for reading and `false`

when the text stream is
opened for writing.

`encoding(Encoding)`

— `Encoding`

is an
atom representing the text encoding that shall be used when opening
the stream for writing or the text encoding of the stream opened for
reading.

When opening the text stream for reading with the
default `bom(Bool)`

streamoption value or by explicitly
specifying the `bom(true)`

stream-option, if a *Byte
Order Mark* is detected, it will be used to set the corresponding
Unicode text stream encoding, overriding
any `encoding(Encoding)`

that might be also specified.

NOTES

1 These stream-options imply the
stream-option `type(text)`

.

2 The set of supported text encodings is implementation-defined.

`bom(Bool)`

— If present and if `Bool`

(7.1.4.2) is `true`

, a Unicode encoding *Byte Order
Mark* was detected while opening the text stream for reading or a
*Byte Order Mark* was written while opening the text stream for
writing.

7 LANGUAGE CONCEPTS AND SEMANTICS 5

`encoding(Encoding)`

— Encoding used for the text
stream.

NOTE — These stream properties imply the stream
property `type(text)`

.

Possible values: the default value only

Default: implementation defined

Changeable: No

Description: The value of this flag is the number of significant digits on the mantissa of a normalized floating point number (in base 10), an implementation defined integer value.

Possible values: the default value only

Default: implementation defined

Changeable: No

Description: The value of this flag is the distance
from `1.0`

to the next largest floating point number, an
implementation defined value. Thus, it allows the programmer to query
an implementation about the relative accuracy when performing
arithmetic with floating point numbers.

Possible values: the default value only

Default: implementation defined

Changeable: No

Description: The value of this flag is smallest possible value of the exponent of a normalized floating point number, an implementation defined integer value.

7 LANGUAGE CONCEPTS AND SEMANTICS 6

Possible values: the default value only

Default: implementation defined

Changeable: No

Description: The value of this flag is greatest value of the exponent of a normalized floating point number, an implementation defined integer value.

Possible
values: `fail`

, `cyclic`

, `unsafe`

Default: implementation defined

Changeable: No

Description: This read-only flag describes the behaviour of the
Prolog system when a variable is unified with a compound term that
contains it (STO unification, 3.165). The flag value `fail`

implies that STO unification simply fails. The flag
value `unsafe`

means that if an STO unification is
encountered the further behavior of the system is undefined. The flag
value `cyclic`

implies that STO unifications will be
successful and result in the creation of cyclic terms. Moreover, this
flag indicates that the Prolog system is capable of handling certain
operations on cyclic terms *safely*, namely unifying,
comparing, and copying of cyclic terms is assured to terminate.

NOTES

1 The flag value `fail`

means that the built-in
predicate `=/2`

(8.2.1) behaves exactly as the built-in
predicate `unify_with_occurs_check/2`

(8.2.2). The flag
value `unsafe`

may imply that the STO unification itself,
or further unifications or built-in predicate calls may not terminate,
or cause the system to fail or raise an exception.

2 A conforming Prolog processor which supports the creation of
cyclic terms shall be accompanied by documentation that specifies
which built-in predicates may be safely called with arguments which
are cyclic terms.

Examples:

| ?- X = f(X).

7 LANGUAGE CONCEPTS AND SEMANTICS 7

`fail`

: fails`cyclic`

: succeeds and unifies`X`

with a cyclic term`f(f(f(...)))`

.`unsafe`

: undefined. Often succeeds, but subsequent use of`X`

, as e.g. in`X=X`

, causes an error.

| ?- X = f(X), Y = f(Y), X = Y. | ?- g(X,Y,X) = g(f(X),f(Y),Y). | ?- X = f(X), Y = f(Y), X == Y. | ?- X = f(X), asserta(p(X)).For all the above four examples:

`fail`

: fails`cyclic`

: succeeds and unifies both`X`

and`Y`

with a cyclic term`f(f(f(...)))`

.`unsafe`

: undefined. Often causes an error.

Possible values: an implementation defined atom

Default: implementation defined

Changeable: implementation defined

Description: This flag represents the default encoding for text streams. An implementation shall document if the flag value can be changed by programmer as well all the supported encodings.

- a) The list of valid types is extended by the addition of
`pair`

(see 7.12.2 b of ISO/IEC 13211-1). - b) The list of valid domains is extended by the addition of
`order`

and`predicate_property`

(see 7.12.2 c of ISO/IEC 13211-1).

8 BUILT-IN PREDICATES 8

`property(Callable, Property)`

,
where `Callable`

is a callable term. The predicate
properties supported shall include:
`static`

— The predicate is static`dynamic`

— The predicate is dynamic`built_in`

— The predicate is a built-in predicate`multifile`

— The predicate is the subject of a multifile directive

`subsumes(General, Specific)`

is true iff there is a
substitution `subsumes(?term, @term)`

subsumes(f(X,Y), f(Z,Z)). Succeeds, unifying both X and Y to Z. subsumes(f(Z,Z), f(X,Y)). Fails.

8 BUILT-IN PREDICATES 9

`callable(Term)`

is true iff `Term`

is a callable term.
`callable(@term)`

callable(a). Succeeds. callable(3). Fails.

`ground(Term)`

is true iff `Term`

is a ground term.
`ground(@term)`

ground(3). Succeeds. ground(a(1, _)). Fails.

8 BUILT-IN PREDICATES 10

`acyclic(Term)`

is true iff `Term`

is an acyclic
term. For implementations not supporting STO unification 7.11.3.6,
calls to this predicate simply succeed.
`acyclic(@term)`

acyclic(a(1, _)). Succeeds. X = f(X), acyclic(X). Fails.

`cyclic(Term)`

is true iff `Term`

is a cyclic
term. For implementations not supporting STO unification 7.11.3.6,
calls to this predicate simply fail.
`cyclic(@term)`

cyclic(a(1, _)). Fails. X = f(X), cyclic(X). Succeeds.

8 BUILT-IN PREDICATES 11

`compare(Order, Term1, Term2)`

is true
iff `Order`

corresponds to the standard order
between `Term1`

and `Term2`

. The
argument `Order`

is unified with the atom <
when `Term1`

is less than `Term2`

, with the
atom `=`

when `Term1`

and `Term2`

are
equal, and with the atom `>`

when `Term1`

is
greater than `Term2`

.
`compare(?atom, @term, @term)`

- a)
`Order`

is neither a variable nor an atom

—`type_error(atom, Order)`

- b)
`Order`

an atom other than`<`

,`=`

, or`>`

—`domain_error(order, Order)`

compare(Order, 3, 5). Succeeds, unifying Order with <. compare(Order, d, d). Succeeds, unifying Order with =. compare(Order, 3, 3.0). Succeeds, unifying Order with >.

`numbervars(Term, Start, End)`

is true. This predicate
unifies each free variable on `Term`

with a compound term
with the format `'$VAR'(N)`

where `N`

is an
integer starting from `Start`

and ending
at `End-1`

.
`numbervars(?nonvar, +integer, -integer)`

8 BUILT-IN PREDICATES 12

- a)
`Start`

is a variable

—`instantiation_error`

- b)
`Start`

is neither a variable nor an integer

—`type_error(integer, Start)`

numbervars(foo(A, B, A), 0, End). Succeeds, unifying A with '$VAR'(0), B with '$VAR'(1), and End with 2.

`predicate_property(Head, Property)`

is true iff the
procedure associated with the argument `Head`

(3.84) has
predicate property `Property`

.
Procedurally, `predicate_property(Head, Property)`

is
executed as follows

- a) Determines the principal functor
`P`

and arity`N`

associated with`Head`

.`P/N`

is the associated predicate indicator - b) Searches the complete database and creates a set
*SetPP*of all terms PP such that`P/N`

identifies a procedure which has predicate property PP and PP is unifiable with`Property`

- c) If
*SetPP*is non empty set proceeds to 8.8.3.1 e, - d) Else the goal fails
- e) Chooses the first element PPP of
*SetPP*, unifies PPP with`Property`

and the predicate succeeds - f) If all elements of
*SetPP*have been chosen the predicate fails - g) Else chooses the first element PPP of
*SetPP*that has not already been chosen, unifies PPP with`Property`

and the goal succeeds

`predicate_property(Head, Property)`

is re-executable. On
backtracking, continue at 8.8.3.1 f.
The order in which properties are found
by `predicate_property/2`

is implementation dependent.

8 BUILT-IN PREDICATES 13

NOTES

1 A processor may support, as an implementation specific feature,
additional predicate properties.

2 For a dynamic predicate, all proprieties related to its
definition shall be removed when the predicate is abolished.

`predicate_property(@callable_term, ?predicate_property)`

- a)
`Head`

is a variable

—`instantiation_error`

- b)
`Head`

is neither a variable nor a callable term

—`type_error(callable, Head)`

- c)
`Property`

is neither a variable nor a predicate property

—`domain_error(predicate_property, Property)`

predicate_property(once(_), built_in). Succeeds. predicate_property(atom_codes(_, _), Property). Succeeds unifying Property with static. On re-execution, succeeds unifying Property with built_in.

`permission_error`

exception that should use the atom
`modify`

instead of `access`

in order to match
the specification of other database predicates.- a) ...
- b) ...
- c) The predicate indicator
`Pred`

of`Head`

is that of a static procedure

—`permission_error(modify, static_procedure, Pred)`

8 BUILT-IN PREDICATES 14

`retractall(Head)`

is true.
Procedurally, `retractall(Head)`

is executed as follows:

- a) Determines the principal functor
`P`

and arity`N`

associated with`Head`

.`P/N`

is the associated predicate indicator - b) If the database contains a dynamic procedure whose predicate
indicator is
`P/N`

, then proceeds to 8.9.5.1 d, - c) Else the goal succeeds.
- d) Retracts from the database all clauses whose head unifies with
`Head`

and the goal succeeds

NOTES

1
The dynamic predicate shall continue to be known by the system
even when all of its clauses are removed.

2
This predicate does not change any of the standard predicate
properties of the referenced predicate (as reported
by `predicate_property(Head, Property)`

), even when all of
its clauses are removed.

`retractall(@callable_term)`

- a)
`Head`

is a variable

—`instantiation_error`

- b)
`Head`

is neither a variable nor a callable term

—`type_error(callable, Generate)`

- c) The predicate indicator
`Pred`

of`Head`

is that of a static procedure

—`permission_error(modify, static_procedure, Pred)`

8 BUILT-IN PREDICATES 15

:- dynamic(insect/1). insect(ant). insect(bee). insect(spider). retractall(insect(bee)). Succeeds, retracting the clause 'insect(bee)'. retractall(insect(_)). Succeeds, retracting all the clauses of predicate insect/1. retractall(insect(elephant)). Succeeds. retractall(mammal(_)). Succeeds. retractall(3). type_error(callable, 3)

`forall(Generate, Test)`

is true iff for all possible bindings of
`Generate`

, the goal `Test`

is
true. Procedurally, abstracting error checking, the predicate shall
behave as being defined by ```
\+ (call(Generator), \+
call(Test)).
```

`forall(@callable_term, @callable_term)`

- a)
`Generate`

is a variable

—`instantiation_error`

- b)
`Generate`

is neither a variable nor a callable term

—`type_error(callable, Generate)`

- c)
`Test`

is a variable

—`instantiation_error`

- d)
`Test`

is neither a variable nor a callable term

—`type_error(callable, Test)`

8 BUILT-IN PREDICATES 16

`a/1`

and `b/1`

are defined with the following clauses:
a(1). a(2). a(3). b(1, a). b(2, b). b(3, c). forall(fail, true). Succeeds. forall(a(X), b(X, _)). Succeeds. forall(a(X), b(_, X)). Fails. forall(b(_, Y), write(Y)) Succeeds, outputting the characters abc to the current output stream.

`call(Closure, Arg1, ...)`

is true
iff `call(Goal)`

is true where `Goal`

is
constructed by appending `Arg1, ...`

additional arguments to the
arguments (if any) of `Closure`

.
`call(@callable_term, ?term, ...)`

- a)
`Closure`

is a variable

—`instantiation_error`

- b)
`Closure`

is neither a variable nor a callable term

—`type_error(callable, Closure)`

- c) The number of arguments in the resulting goal exceeds the
implementation defined maximum arity for compound
terms

—`representation_error(max_arity)`

8 BUILT-IN PREDICATES 17

call(integer, 3). Succeeds. call(atom_concat(pro), log, Atom). Succeeds, unifying Atom with prolog.

`call_cleanup(Goal, Cleanup)`

is true
iff `call(Goal)`

is true. When the execution
of `Goal`

terminates, either by deterministic success, by
failure, by its choice-points being cut, or by raising an exception,
the goal `Cleanup`

is executed. The success or failure
of `Cleanup`

is ignored, as are any choice-points created
while proving it. An exception thrown by `call(Goal)`

may
be caught by `Cleanup`

. An exception thrown
by `Cleanup`

is handled as normal.
`call_cleanup(+callable_term, @callable_term)`

- a)
`Goal`

is a variable

—`instantiation_error`

- b)
`Goal`

is neither a variable nor a callable term

—`type_error(callable, Goal)`

- c)
`Cleanup`

is a variable

—`instantiation_error`

- d)
`Cleanup`

is neither a variable nor a callable term

—`type_error(callable, Cleanup)`

call_cleanup(true, write(terminated)). Succeeds, outputting the atom terminated to the current output stream. catch(call_cleanup(throw(e), catch(true, E, throw(E))), F, true). Succeeds, unifying F with e.

8 BUILT-IN PREDICATES 18

`append(List1, List2, List3)`

is true
iff `List3`

is a list resulting from the concatenation
of `List1`

and `List2`

.
`append(?list, ?list, ?list)`

`append/3`

:
append([], List, List). Succeeds.

`length(List, Length)`

is true iff `Length`

is
the length of the list `List`

.
`length(?list, ?integer)`

- a)
`Length`

is neither a variable nor an integer

—`type_error(integer, Length)`

length([1, 2, 3], Length). Succeeds, unifying Length with 3. length(List, 3). Succeeds, unifying List with [_, _, _]

8 BUILT-IN PREDICATES 19

length(List, -2). Fails length(List, Length). List = [] Length = 0 ; List = [_] Length = 1 ; List = [_, _] Length = 2 yes

`member(Element, List)`

is true iff `Element`

is
a member of list `List`

.
`member(?term, ?list)`

member(2, [1, 2, 3]). Succeeds.

`sort(List, Sorted)`

is true iff `Sorted`

is a
list containing the non-duplicated elements of `List`

sorted in ascending order following standard order (7.2).
`sort(@list, ?list)`

8 BUILT-IN PREDICATES 20

- a)
`List`

is a partial list

—`instantiation_error`

- b)
`List`

is neither a partial list nor a list

—`type_error(list, List)`

- c)
`Sorted`

is neither a partial list nor a list

—`type_error(list, Sorted)`

sort([1, 2, 1, 8, 4], Sorted). Succeeds, unifying Sorted with [1, 2, 4, 8].

`keysort(List, Sorted)`

is true iff `List`

is a
list of elements with the format `Key-Value`

and `Sorted`

is a list containing the elements
of `List`

sorted according to the value of `Key`

in ascending order following standard order (7.2). The relative order
of elements of `List`

with the same key shall not change in
the `Sorted`

list.
`keysort(@list, ?list)`

- a)
`List`

is a partial list

—`instantiation_error`

- b)
`List`

is neither a partial list nor a list

—`type_error(list, List)`

- c) An element
`Element`

of`List`

is a variable

—`instantiation_error`

- d) An element
`Element`

of`List`

is neither a variable nor a`'-'/2`

compound term

—`type_error(pair, Element)`

- e)
`Sorted`

is neither a partial list nor a list

—`type_error(list, Sorted)`

9 EVALUABLE FUNCTORS 21

keysort([1-a, 3-f(_), 1-z, 2-44], Sorted). Succeeds unifying Sorted with [1-a, 1-z, 2-44, 3-f(_)].

Evaluable functor | Operation |

`(+)/1` | pos_{I} , pos_{F} |

*pos _{I} : I → I*

For all *x ∈ I*, the following axioms shall apply:

*pos _{I} (x) = x*

*pos _{F} : F → F*

For all *x ∈ F*, the following axioms shall apply:

*pos _{F} (x) = x*

`log(B, X)`

evaluates the expression `B`

with
value `VB`

, the expression `X`

with
value `VX`

, and has the value of the logarithm to base
`VB`

of `VX`

.
9 EVALUABLE FUNCTORS 22

`log(int-exp, float-exp) = float`

`log(int-exp, int-exp) = float`

- a)
`B`

is a variable

—`instantiation_error`

- b)
`B`

is not a variable and`VB`

is not an integer

—`type_error(integer, VB)`

- c)
`VB`

is zero or negative

—`evaluation_error(undefined)`

- d)
`X`

is a variable

—`instantiation_error`

- e)
`X`

is not a variable and`VX`

is not a number

—`type_error(number, VX)`

- f)
`VX`

is zero or negative

—`evaluation_error(undefined)`

log(10, 10.0). Evaluates to 1.0.

`gcd(I, J)`

evaluates the expression `I`

with
value `VI`

, the expression `J`

with
value `VJ`

, and has the value of the greatest common
divisor of `VI`

of `VJ`

.
`gcd(int-exp, int-exp) = integer`

- a)
`I`

is a variable

—`instantiation_error`

- b)
`I`

is not a variable and`VI`

is not an integer

—`type_error(integer, VI)`

9 EVALUABLE FUNCTORS 23

- c)
`J`

is a variable

—`instantiation_error`

- d)
`J`

is not a variable and`VJ`

is not an integer

—`type_error(integer, VJ)`

gcd(2, 3). Evaluates to 1.

`min(X, Y)`

evaluates the expression `X`

with
value `VX`

, the expression `Y`

with
value `VY`

, and has the value of the minimum
of `VX`

and `VY`

. When used with expressions of
mixed-types, the result is implementation-dependent; an implementation
may chose either to return a value or to throw an exception.
`min(float-exp, float-exp) = float`

`min(float-exp, int-exp) = implementation-dependent result`

`min(int-exp, float-exp) = implementation-dependent result`

`min(int-exp, int-exp) = integer`

- a)
`X`

is a variable or`Y`

is a variable

—`instantiation_error`

- b)
`X`

is not a variable and`VX`

is not a number

—`type_error(number, VX)`

- c)
`Y`

is not a variable and`VY`

is not a number

—`type_error(number, VY)`

min(2, 3) Evaluates to 2. min(2.0, 3.0) Evaluates to 2.0. min(0, 0.0). Implementation-dependent result.

9 EVALUABLE FUNCTORS 24

`max(X, Y)`

evaluates the expression `X`

with
value `VX`

, the expression `Y`

with
value `VY`

, and has the value of the maximum
of `VX`

and `VY`

. When used with expressions of
mixed-types, the result is implementation-dependent; an implementation
may chose either to return a value or to throw an exception.
`max(float-exp, float-exp) = float`

`max(float-exp, int-exp) = implementation-dependent result`

`max(int-exp, float-exp) = implementation-dependent result`

`max(int-exp, int-exp) = integer`

- a)
`X`

is a variable or`Y`

is a variable

—`instantiation_error`

- b)
`X`

is not a variable and`VX`

is not a number

—`type_error(number, VX)`

- c)
`Y`

is not a variable and`VY`

is not a number

—`type_error(number, VY)`

max(2, 3) Evaluates to 3. max(2.0, 3.0) Evaluates to 3.0. max(0, 0.0). Implementation-dependent result.

`'><'(B1, B2)`

evaluates the
expressions `B1`

and `B2`

with
values `VB1`

and `VB2`

and has the value such
that each bit is set iff only one of the corresponding bits
in `VB1`

and
`VB2`

is set.
The value shall be implementation defined if `VB1`

or `VB2`

is negative.

9 EVALUABLE FUNCTORS 25

`'><'(int-exp, int-exp) = integer`

NOTE — '><' is an infix predefined operator (see 6.3.4.4).

- a)
`B1`

is a variable

—`instantiation_error`

- b)
`B2`

is a variable

—`instantiation_error`

- c)
`B1`

is not a variable and`VB1`

is not an integer

—`type_error(integer, VB1)`

- d)
`B2`

is not a variable and`VB2`

is not an integer

—`type_error(integer, VB2)`

'><'(10, 12). Evaluates to the value 6. '><'(125, 255). Evaluates to to the value 130. '><'(-10, 12). Evaluates to an implementation defined value. '><'(77, N) instantiation_error. '><'(foo, 2) type_error(integer, foo).

9 EVALUABLE FUNCTORS 26

`tan(X)`

evaluates the expression `X`

with
value `VX`

and has the value of the tangent
of `VX`

(measured in radians).
`tan(float-exp) = float`

`tan(int-exp) = float`

- a)
`X`

is a variable

—`instantiation_error`

- b)
`X`

is not a variable and`VX`

is not a number

—`type_error(number, VX)`

tan(pi). Evaluates to 0.0.

`asin(X)`

evaluates the expression `X`

with
value `VX`

and has the value of the arc sine
of `VX`

(in radians).
`asin(float-exp) = float`

`asin(int-exp) = float`

- a)
`X`

is a variable

—`instantiation_error`

- b)
`X`

is not a variable and`VX`

is not a number

—`type_error(number, VX)`

asin(1.0). Evaluates to a value approximately equal to 1.570796326795.

9 EVALUABLE FUNCTORS 27

`acos(X)`

evaluates the expression `X`

with
value `VX`

and has the value of the arc cosine
of `VX`

(in radians).
`acos(float-exp) = float`

`acos(int-exp) = float`

- a)
`X`

is a variable

—`instantiation_error`

- b)
`X`

is not a variable and`VX`

is not a number

—`type_error(number, VX)`

acos(0.0). Evaluates to a value approximately equal to 1.570796326795.

`atan(Y, X)`

evaluates the expression `Y`

with
value `VY`

, the expression `X`

with
value `VX`

, and computes the principal value of the arc
tangent of `VY/VX`

(in radians), using the signs of both
arguments to determine the quadrant of the return value. When both
arguments are `0.0`

, an implementation-dependent value is
returned.
`atan(float-exp, float-exp) = float`

`atan(float-exp, int-exp) = float`

`atan(int-exp, float-exp) = float`

`atan(int-exp, int-exp) = float`

- a)
`X`

is a variable

—`instantiation_error`

- b)
`Y`

is not a variable and`VY`

is not a number

—`type_error(number, VY)`

9 EVALUABLE FUNCTORS 28

- c)
`X`

is not a variable and`VX`

is not a number

—`type_error(number, VX)`

atan(0.0, -0.0). Evaluates to a value approximately equal to 3.14159265358979.

`pi`

evaluates to the floating-point number which best
approximates the mathematical constant pi. Evaluates to the corresponding mathematical constant. The accuracy of the result is implementation-defined.

`e`

evaluates to the floating-point number which best
approximates the mathematical constant e. Evaluates to the corresponding mathematical constant. The accuracy of the result is implementation-defined.

`epsilon`

evaluates to the distance from `1.0`

to the next largest floating point number, an implementation defined
value. Thus, it allows the programmer to retrieve the relative
accuracy when performing arithmetic with floating point numbers.
9 EVALUABLE FUNCTORS 29

epsilon. Evaluates to an implementation defined value.

Validated HTML