Deleted text is in Strikethrough, inserted text
is underlined.
5.5.12 Options.
A processor may support one or more additional options such as stream options (7.10.2.11), stream close options (7.10.2.12), read options (7.10.3), and write options (7.10.4) as an implementation specific feature. An invalid optionE
shall be associated with only two error conditions: an instantiation error when there is an instance (3.95) ofE
that is a valid option, and a domain error for the domainxxx_option
when there is no instance ofE
that is a valid option. Further, an instantiation error may occur in place of a domain error if a component ofE
is a variable, and an instantiated component is required.
- NOTE A valid option may still imply further errors ; as in 8.11.5.3 l and m.
p text = [ layout text sequence (* 6.4.1 *) ] ;
a) If Tunifies withhas the form^(_, G)
then ...
Table 21 and 22 show the execution stack before and
after executing the control constructcall(G)
with goal
obtained fromG
via 7.6.2 Converting a term to the body of a clause.
N + 1 ( (goal, N 1), Σ nilG
variable_names/1
and singletons/1
.
variable_names(VN_list)
After inputting a
term,VN_list
shall be unified with a list of ele-
ments where: (1) each element is a termA = V
, and
(2)V
is a named variable of the term, and (3)A
is an
atom whose name is the characters ofV
, and (4) the elements appear in the order of the first occurrence of their variablesV
in the term input, in left-to-right traversal order.
singletons(VN_list)
After inputting a term,
VN_list
shall be unified with a list of elements
where: (1) each element is a termA = V
, and (2)V
is
a named variable which occurs only once in the term,
and (3)A
is an atom whose name is the characters ofV
,
and (4) the elements appear in the order of the first occurrence of their variablesV
in the term input, in left-to-right traversal order.
variable_names(VN_list)
before option
numbervars(Bool)
in analogy to
the read-option variable_names(VN_list)
.
Replace an by a non-negative in
write-option numbervars(Bool)
.
variable_names(VN_list)
Each variableV
is output as the unquoted atom (@@@better: is output as the sequence of characters defined by the syntax for the atom)A
iff a termA = V
is an element of the listVN_list
. If more than one element applies, the leftmost is used.
numbervars(Bool)
- IffBool
(7.1.4.2) istrue
a
term of the form'$VAR'(N)
, whereN
isana non-negative integer, is
output as a variable name consisting of a capital letter
possibly followed by an integer.
variable_names(VN_list)
any instance (3.95) (obtained via unification) of a term obtained with the corresponding
read-option is well defined.
@@@ Actually, only the selection of the variable names to be
printed is well defined.
variable_names/1
, correct terminology and writing of {}, lists,
extra round brackets
a1) IfTerm
is a variable and there is an effective write-optionvariable_names(VN_list)
and there is an elementA = Term
of the listVN_list
withA
an atom, thenA
is output with effective write-optionquoted(false)
.
e)e1) IfTerm
has the form'$VAR'(N)
for somepos-non-negative integer N, and there is an effective write-option
itive
numbervars(true)
, a variable name as defined in
subclause 7.10.4 is output,
g)e2) Else ifTerm
has the form'.'(Head, Tail)
, and
there is an effective write-optionignore_ops(false)
,
thenTerm
is output using list notation, that is:
- 1)
[
(open list char) is output.- 2)
Head
is output by recursively applying these
rules.Head
is preceded by(
(open char)
and followed by)
(close char), if the term could not be
re-input correctly with the same set of current operators.
- 3) If
Tail
has the form'.'(H,T)
then,
(comma
char) is output, setHead:=H
,Tail:=T
, and goto (2).- 4) If
Tail
is[]
then a closing bracket]
(close list
char) is output,- 5) Else a
|
(head tail separator char) is output,
Tail
is output by recursively applying these rules,
Tail
is preceded by(
(open char)
and followed by)
(close char), if the term could not be
re-input correctly with the same set of current operators,
and finally,]
(close list char) is output.
e3) Else ifTerm
has the form'{}'(Arg)
, and there is an effective write-optionignore_ops(false)
, thenTerm
is output as a curly bracketed term (6.3.6), that is:
- 1)
{
(open curly char) is output- 2)
Arg
is output by recursively applying these rules- 3)
}
(close curly char) is output
f) Else ifTerm
has a principal functor which is not
a current operator, or if there is an effective write-
optionignore_ops(true)
, then the term is output in
canonical formfunctional notation (6.3.3), that is:
- 1) The atom of the principal functor is output.
- 2)
(
(open char) is output.- 3) Each argument of the term is output by recursively
applying these rules. The argument is preceded by(
(open char) and followed by)
(close char), if the term could not be re-input correctly with the same set of current operators.- 4)
,
(comma char) is output between each successive
pair of arguments.- 5)
)
(close char) is output.
h)IfElse ifTerm
has a principal functor which is an
operator, and there is an effective write-option
ignore_ops(false)
, then the term is output in operator
form, that is:1) The atom of the principal functor is output
in front of its argument (prefix operator), between
its arguments (infix operator), or after its argument
(postfix operator). In all cases, a space is output
to separate an operator from its argument(s) if any
ambiguity could otherwise arise.Operators
','
and'|'
are output as,
(comma char) and|
(bar char) respectively.2) Each argument of the term is output by recursively
applying these rules.When anAn argumentis itselfis preceded by (
to be output in operator form, it
(open char) and followed by ) (close char) if: (i) the
principal functor is an operator whose priority is so
high that the term could not be re-input correctly with
same set of current operators, or (ii) the argument is
an atom which is a current operator, or (iii) the principal functor is output as a prefix operator-
and the argument is a non-negative number, or (iv) the principal functor is output as a prefix operator-
and the argument is output in infix or postfix operator form.
float
to the set ValidType
.
character_code_list
ValidDomain
.
PermissionType ∈ {
binary_stream flag,
7 When a built-in predicate has an argument whose type is a list of options (@@@ as input?), that argument will be an +oname_options_list. (There should be a type oname_options_list used in Template and Modes, and a corresponding domain_error(oname_option, Culprit)). That argument will always be associated withErrors caused by a well-formed option are not subsumed by the domain error. They are reported differently. @@@using different errors.
- an instantiation error, when the argument is a partial list, or an element is not a valid option but an instance of the element is a valid option.
- a domain error, when an element is neither a valid option nor any instance is a valid option.
- additionally, an instantation error may occur in place of the domain error, if ...@
type_error(evaluable,unbound)
when Prolog flag
bounded is false. @@@ *** Need to say that max_arity is unbound
e) Constructs the clause with headH
and bodyB
G
[a, b, f(b), f(a)]
as in IS 13211-1:1995.
b) the goal succeeds.
Add to the four subclauses 8.11.5.3 i, 8.11.6.3 e, 8.14.1.3 e, 8.14.2.3 e using in place of stream-option for the latter three close-option, read-option, and write-option respectively:
- c)
Options
is a partial list or a list with an element
E
which is a variable or which has a component
which is a variable, and an instantiated component is required.
instantiation_error.
- i) An element
E
of the Options list is neither a
variable nor a stream-option and there is no instance ofE
that is a stream-option.
domain_error(stream_option, E).
- k) Parses
C_Seq
as a read-term(6.4)(6.2.2)T.
,
write_term(1,[quoted(non_boolean)]).
domain_error(write_option,quoted(non_boolean)),
write_term(1,[quoted(B)]).
instantiation_error.
B = true, write_term(1,[quoted(B)]).
Succeeds, outputting the character 1.
Replace three times .
by ','
and
remove a space.
write_canonical([1,2,3]).
Succeeds, outputting the characters.(1,.(2,.(3,[ ]'.'(1,'.'(2,'.'(3,[])))
to the current output stream.
Replace domain in error in fourth example:
set_prolog_flag(date, 'July 1988').
domain_error(flagprolog_flag, date).
Replace Y
by VY
:
c)VX
is negative andY
VY
is not.
(^)/2
, when resulting value is not an
integer but still a real number.
- e)
VX
andVY
are integers andVX
is not equal to 1 andVY
is less than -1VY
is negative andVX
is not equal to 1, 0, or -1.
type_error(float, VX).
2^(-1).
evaluation_error(undefined).type_error(float, 2).