ISO/IEC JTC1 SC22 WG17
post-N246 Read- and Write-Option variable_names/1
and Error Handling in Options

(see also all documents, Syntax)

History

2010-11 Vulnerability issues of '$VAR'
draft (superseded) draft 7.10.5
2012-09-05 Resolution A5, add write-option for Cor.3
2013-08 N246
2014-07-22 WDCor.3 supersedes previous drafts!
2017-07-18 Cor.3 published

The Query entry below including a newline character at the end is sent to read(X),catch(X,error(E,_),true). The comment /**/ is replaced by the last preceding entry not containing /**/.

#
 
Query ISO/IEC 13211-1
Cor.3
IF
V5.1B*
MINERVA
2.4
Jekejeke
1.5.0
GNU
1.6.0
B
7.8b7
YAP
6.3.4
SWI**
6.3.16-54
SICStus
4.4.1
ECLiPSe
7.0dev#23 -L iso
Scryer
v0.8.123-750
Trealla
2.34.19
Ichiban
1.2.1
#QueryCodexIFMINERVAJekejekeGNUBYAPSWISICStusECLiPSeScryerTreallaIchiban
conformance of 73 72 48 45 36 65 25 49 46 73 72 73 73 72
regular use of 23 23 22 22 21 23 7 22 22 23 22 23 23 23
introduced WDCor.3 V5.0B <2.4 <0.9.2 <1.4.2 7.8b6 6.3.8 4.3β1 7.0#21 0.8.80 1.9.24 0.10.3
date 2012-09 1996-05 <1997-06 2011-10 2012-04 2012-07 2013-01 2013-01 2013-11 2017-06 2019-05 2021-06 2022-08
manual C6 C14 remote remote remote remote remote
1 write_term(T,[quoted(true),
 variable_names([N=T])]).
i._e. _164 _749 OK OK new _338 OK new OK OK new OK OK OK OK
2 N = 'X', /**/ X OK OK OK OK 'X' OK OK OK OK OK OK OK
3 N = T, /**/ i._e. _164 _533 OK OK new _310 OK new OK OK new OK OK OK OK
4 N = '_', /**/ _ OK OK OK OK '_' OK OK OK OK OK OK OK
65 N = '_/*.*/', /**/ _/*.*/ OK OK d._e.(v._n., x) OK '_/*.*/' OK d._e.(v._n., x) OK OK new OK OK OK
5 N = x, /**/ x OK OK d._e.(v._n., x) OK new OK OK d._e.(v._n., x) OK OK new OK OK OK
6 N = 'x+y', /**/ x+y OK OK d._e.(v._n., 'x+y') OK new 'x+y' OK d._e.(v._n., 'x+y') OK OK new OK OK OK
50 N = '))', /**/ )) OK OK d._e.(v._n., '))') OK new '))' OK d._e.(v._n., '))') OK OK new OK OK OK
7 N = 7, /**/ d._e.(w._o., v._n.(..)) _168 7 t._e.(at., 7) OK new 7 H t._e.(at., 7) OK OK OK OK new OK
8 N = 1+2, /**/ d._e.(w._o., v._n.(..)) _171 +(1,2) t._e.(at., 1+2) OK new 1+2 '$VAR'(1+2) t._e.(at., 1+2) OK OK OK OK new OK
9 N = '$VAR'(9), /**/ d._e.(w._o., v._n.(..)) _170 '$VAR'(9) t._e.(at., ...) OK new J '$VAR'(J) t._e.(at., ...) OK OK OK OK new OK
10 T = a, /**/ i._e. a a a OK new a OK new OK OK new OK OK OK OK
11 T = a, N = 'Any', /**/ a OK OK OK OK OK OK OK OK OK OK OK OK
12 T = '$VAR'(9), N = '_', /**/ '$VAR'(9) OK OK OK OK J J OK OK OK OK OK new OK
28 freeze(T,throw(g(T))),
N = 'X', /**/
X OK n/a OK n/a g(X) OK OK OK OK OK OK n/a
13 write_term(T,[quoted(true),
 variable_names([
  'X'=X,'Y'=Y,'Z'=Z])]).
_Impdep _164 _583 _D _23 _420 _1.. _G864 _981 _391 _0 _0 new _1159
14 T=(X,Y,Z), /**/ X,Y,Z X , Y , Z X , Y , Z OK OK 'X','Y','Z' OK OK OK OK OK OK OK
15 Z=Y, T=(X,Y,Z), /**/ X,Y,Y X , Y , Y X , Y , Y OK OK 'X','Y','Y' OK OK OK OK OK OK OK
16 Z=Y, Y=X, T=(X,Y,Z), /**/ X,X,X X , X , X X , X , X OK OK 'X','X','X' OK OK OK OK OK OK OK
17 T=(Y,Z), /**/ Y,Z Y , Z Y , Z OK OK 'Y','Z' OK OK OK OK OK OK OK
18 T=(Z,Y), /**/ Z,Y Z , Y Z , Y OK OK 'Z','Y' OK OK OK OK OK OK OK
19 write_term(T,[quoted(true),
 variable_names([
  'Z'=Z,'Y'=Y,'X'=X])]).
_Impdep _164 _583 _D _23 _3b4 _1.. _G864 _981 _391 _0 _0 new _1159
20 T=(X,Y,Z), /**/ X,Y,Z X , Y , Z X , Y , Z OK OK 'X','Y','Z' OK OK OK OK OK OK OK
21 Z=Y, T=(X,Y,Z), /**/ X,Z,Z X , Z , Z X , Z , Z X, Z, Z new OK 'X','Z','Z' OK OK OK OK OK OK new OK
22 Z=Y, Y=X, T=(X,Y,Z), /**/ Z,Z,Z Z , Z , Z Z , Z , Z Z, Z, Z new OK 'Z','Z','Z' OK OK OK OK OK OK new OK
23 T=(Y,Z), /**/ Y,Z Y , Z Y , Z OK OK 'Y','Z' OK OK OK OK OK OK OK
24 T=(Z,Y), /**/ Z,Y Z , Y Z , Y OK OK 'Z','Y' OK OK OK OK OK OK OK
25 write_term(T,[quoted(true),
 variable_names([
  'X'=Z,'X'=Y,'X'=X])]).
_Impdep _164 _583 _D _23 _3b4 _1.. _G864 _981 _391 _0 _0 new _1159
26 T=(X,Y,Z), /**/ X,X,X X , X , X X , X , X OK OK 'X','X','X' OK OK OK OK OK OK OK
27 T=(1,2,3), T=(X,Y,Z), /**/ 1,2,3 1 , 2 , 3 1 , 2 , 3 OK OK OK OK OK OK OK OK OK OK
32 read_term(T,[
 variable_names(VN_list)]),
VN_list=[_=1,_=2,_=3],
writeq(VN_list).
waits OK OK OK OK OK OK OK OK OK OK OK OK
29 /**/ B+C+A+B+C+A. ['B'=1,'C'=2,'A'=3]³ OK OK OK new OK ['A'=1,
'C'=2, 'B'=3]
OK OK OK new OK OK new OK OK
30 write_term(T,
 [variable_names(VN_list)]).
i._e. _164 loops OK OK new OK _131777 OK OK new OK new OK OK new OK
31 VN_list = 1, /**/ d._e.(w._o.,v._n.(..)) _168 _707 t._e.(list, 1) OK wrong_coll. _131821 t._e.(list, 1) OK new OK new OK OK OK
33 VN_list = [[]], /**/ d._e.(w._o.,v._n.(..)) _170 _772 t._e.(assoc, []) OK _388 fails t._e.(v._ass., []) OK OK new OK OK OK
34 VN_list = non_list,/**/ d._e.(w_.o.,v._n.(..)) _168 _707 t._e.(list, n.) OK wrong_coll. _131869 t._e.(list, n.) OK new OK new OK OK OK
35 VN_list = [T='T'|non_list],/**/ d._e.(w._o.,v._n.(..))
or i._e.
_165 _630 t._e.(list, n.) i._e. t._e.(list, n.) _131900 i._e. d._e. new i._e. d._e. i._e. i._e.
52 VN_list = ['T'=T|_],/**/ i._e. T T OK OK new OK T OK OK new OK OK OK OK
51 VN_list = ['T'=T|non_list],/**/ d._e.(w._o.,v._n.(..)) T T t._e.(list, n.) OK t._e.(list, n.) T t._e.(list, n.) OK new OK new OK OK new OK
36 VN_list = [T-'T'],/**/ d._e.(w._o.,v._n.(..)) _165 _630 t._e.(assoc, _-'T') OK _350 fails t._e.(v._ass., ...) OK OK new OK OK new OK
63 VN_list = [_,a],/**/ d._e.(w._o.,v._n.(..))
or i._e.
_165 _912 i._e. d._e. i._e. i._e. d._e. i._e. i._e.
64 VN_list = [a,_],/**/ d._e.(w._o.,v._n.(..))
or i._e.
_165 _973 t._e.(assoc,a) d._e. d._e. d._e. new d._e. d._e. d._e.
66 VN_list = [a|_],/**/ d._e.(w._o.,v._n.(..))
or i._e.
_174 loops t._e.(assoc,a) d._e. i._e. d._e. new i._e. d._e. d._e.
67 VN_list = [i=i,7=i],/**/ d._e(w._o.,
v._n.([i=i,7=i])).
_178 _672 _A OK OK _13.. d._e.(v._n.,i) OK OK OK new OK new OK
68 VN_list = [_,_],/**/ i._e. _174 _893 OK d._e... fails OK OK OK OK new OK new OK
43 write_term(-X^2,[
 variable_names(['X'=X])]).
- (X^2) -X^2 -X^2 -X^2 -X^2 -X^2 -X^2 -X^2 OK OK OK OK new OK
44 X=1, /**/ - (1^2) #183/215 #183/215 #183/215 OK OK - (1)^2 #183/215 OK OK OK OK new OK
37 open(f,write,_,[O]). i._e. OK OK O = alias(_) OK OK OK OK OK OK OK new OK OK
38 O = 1, /**/ d._e.(s._o., 1) OK t._e.(atom, 1) d._e.(o._o.,1) OK OK OK OK OK new OK new OK new OK OK
56 O = typex(_), /**/ d._e.(s._o., t.(_)) OK i._e. d._e.(o._o.,..) OK OK succeeds succeeds OK new OK new OK new OK new OK
57 O = typex(1), /**/ d._e.(s._o., t.(1)) OK t._e.(atom, 1) d._e.(o._o.,..) OK OK succeeds succeeds OK OK new OK new OK OK
62 O = typex(s(_)), /**/ d._e.(s._o., t.(s(_.))) OK t._e.(atom, s(_.)) d._e.(o._o.,..) OK OK succeeds succeeds OK OK new OK new OK OK
39 O = type(text), /**/ succeeds OK OK OK OK OK OK OK OK OK OK new OK OK
40 O = type(1), /**/ d._e.(s._o., t.(1)) t._e.(atom, 1) t._e.(atom, 1) t._e.(atom, 1) OK d._e.(s._o., 1) OK t._e.(atom, 1) OK OK new OK new OK OK
41 O = type(_), /**/ i._e. OK OK OK OK new d._e.(s._o.,..) OK new OK OK new OK new OK new OK new OK
60 O = alias(_), /**/ i._e. OK OK p._e.(o.,
s._s.,..)
d._e.(s._., ..) p._e.(o.,
s._s.,..)
OK OK OK new OK new OK new OK new OK
42 O = type(nontype), /**/ d._e.(s._o., t.(n.))   d._e.(s._o., n.) OK   d._e.(flag_v., n.) OK   d._e.(s._o., n.) succeeds OK new OK OK new OK new OK new OK
61 O = alias(1), /**/ d._e.(s._o.. a.(1)) t._e.(a.,a.(1)) OK O = alias(1) OK p._e.(o.,s._s.,..) t._e.(a.,1) t._e.(a.,1) OK OK new OK new OK OK
45 read_term(T,[
 variable_names(VN_list)]).
waits OK OK OK OK OK OK OK OK OK OK OK OK
46 /**/ a. T = a,
VN_list = []
OK OK OK OK OK OK OK OK OK OK OK OK
47 VN_list = 42, /**/ waits OK OK OK d._e.(r._o,..) reg OK OK OK OK OK OK OK new OK
48 VN_list = 42, /**/ a. fails OK OK OK d._e.(r._o,..) reg OK OK OK OK OK OK OK new OK
49 VN_list = 42, /**/ a b. syn._e.(..) OK OK OK d._e.(r._o,..) reg OK OK OK OK OK OK OK new OK
53 write_term(S,[quoted(true),
 variable_names([N=T])]).
i._e. _164 _583 OK OK _328 OK OK OK OK OK OK OK
54 S=1+T,N='/*r*/V',/**/ 1+/*r*/V 1 + /*r*/V 1 + /*r*/V d._e(v._n.,..) 1+ /*r*/V OK d._e(v._n.,..) OK OK new 1+ /*r*/ OK new OK
55 S=1+T,N=' /*r*/V',/**/ 1+ /*r*/V 1 + /*r*/V 1 + /*r*/V d._e(v._n.,..) OK OK d._e(v._n.,..) OK OK new OK OK new OK
58 S=1+T,N=(+),/**/ 1++ or 1+ + 1 + + 1 + + d._e(v._n.,..) 1+ + 1+ + d._e(v._n.,+) 1+ + 1++ 1+ + 1++ new 1++
59 S=T+1,N=(+),/**/ ++1 or + +1 + + 1 + + 1 d._e(v._n.,..) ++1 + +1 d._e(v._n.,+) + +1 + +1 + +1 ++1 new ++1
73 S=(1 is T),N='X',/**/ 1 is X OK OK @@@ OK 1 is 'X' 1 is X OK OK 1 isX OK OK OK new
69 read_term(T,[singletons(1)]). waits OK OK OK d._e.(r.,..) OK OK OK OK OK OK OK new OK
70 /**/ a. fails OK OK OK OK OK OK OK OK OK OK new OK
71 write_term(T,[
variable_names(['Bad'=T]),
variable_names(['Good'=T])]).
Good OK OK @@@ OK new Bad OK OK OK OK OK OK OK
72 read_term(T,[singletons([])]). waits OK OK @@@ OK OK OK OK OK OK OK OK new OK
74 Template @@@
* IF/Prolog was tested with the implementation specific write-option varnames/1 instead. There is also a read-option varnames/1:
variable_names( ? VarList )
If a term is read in successfully, VarList is unified with a list of all named variables found in Term and their names in the form [Name = Variable, ... ], i.e. anonymous variables are not included in the list.
varnames( ? VarList )
If a term is read in successfully, VarList is unified with a list of all variables found in Term and their names in the form [ Name = Variable , ... ] , i.e. anonymous variables are also included.

Note that the name /storage/emulated/0/f was used in place of f.
** Note that SWI discontinued to support this options since approximately 7.3.26. Note that SWI7 is no longer ISO (or striving towards ISO).
No errors/silent ignorance might be justifiable, because 7.10.5 does not foresee any errors. On the other hand, 8.14.2.3 lists already errors that might be applicable for variable_names/1:
e) An element E of the Options list is neither a
variable nor a valid write-option
domain_error(write_option, E).
Also, some errors are specific to a particular option already:
8.11.5.3
l) An element E of the Options list is alias(A) and
A is already associated with an open stream
permission_error(open, source_sink,
alias(A)).

m) An element E of the Options list is
reposition(true) and it is not possible to repo-
sition this stream
permission_error(open, source_sink,
reposition(true)).
Solution in WDCor.3: use instantiation errors and domain errors only.
Version Control, Validated HTML