ISO/IEC JTC1 SC22 WG17
N246 Read- and Write-Option variable_names/1

(see also all documents, Syntax)

History

2010-11 Vulnerability issues of '$VAR'
2012-09-05 Resolution A5, add write-option for Cor.3

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

#
 
Query WDCor.3
IF
V5.1B*
MINERVA
2.4
Jekejeke
0.9.9
GNU
1.4.4
B
7.8
YAP
6.3.4
SWI
6.3.16-54
SICStus
4.3.0beta
conformance
introduced WDCor.3 <0.9.2 <1.4.2 7.8b6 6.3.8
date 2012-09 <1998 <1997-06 2012-04 2012-07 2013-01 2013-01
manual remote remote remote remote
1 write_term(T,[quoted(true),
 variable_names([N=T])]).
inst._e. _164 _749 inst._e. _23 _338 '$VAR'(_1..) inst._e.
2 N = 'X', /**/ X OK OK OK OK 'X' OK OK
3 N = T, /**/ inst._e. _164 _533 inst._e. _23 _310 '$VAR'(...) inst._e.
4 N = '_', /**/ _ OK OK OK OK '_' OK OK
5 N = x, /**/ x x `x` _27 x x do._e.(var._n.,x)
6 N = 'x+y', /**/ x+y x+y `x+y` _27 'x+y' x+y do._e.(var._n.,'x+y')
7 N = 7, /**/ _168 7 ty._e.(at.,7) _27 7 H ty._e.(at.,7)
8 N = 1+2, /**/ _171 +(1,2) ty._e.(at.,1+2) _30 1+2 '$VAR'(1+2) ty._e.(at.,1+2)
9 N = '$VAR'(9), /**/ _170 '$VAR'(9) ty._e.(at.,...) _39 J '$VAR'(J) ty._e.(at.,...)
10 T = a, /**/ a a a a a a inst._e.
11 T = a, N = 'Any', /**/ a a a a a a a a
12 T = '$VAR'(9), N = '_', /**/ '$VAR'(9) OK OK OK OK J J OK
28 freeze(T,throw(g(T))),
N = 'X', /**/
X OK n/a n/a n/a g(X) OK OK
13 write_term(T,[quoted(true),
 variable_names([
  'X'=X,'Y'=Y,'Z'=Z])]).
_Impdep _164 _583 _D _23 _420 _1.. _G864
14 T=(X,Y,Z), /**/ X,Y,Z X , Y , Z X , Y , Z OK OK 'X','Y','Z' 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
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
17 T=(Y,Z), /**/ Y,Z Y , Z Y , Z OK OK 'Y','Z' OK OK
18 T=(Z,Y), /**/ Z,Y Z , Y Z , Y OK OK 'Z','Y' OK OK
19 write_term(T,[quoted(true),
 variable_names([
  'Z'=Z,'Y'=Y,'X'=X])]).
_Impdep _164 _583 _D _23 _3b4 _1.. _G864
20 T=(X,Y,Z), /**/ X,Y,Z X , Y , Z X , Y , Z OK OK 'X','Y','Z' OK OK
21 Z=Y, T=(X,Y,Z), /**/ X,Z,Z X , Z , Z X , Z , Z OK OK 'X','Z','Z' OK OK
22 Z=Y, Y=X, T=(X,Y,Z), /**/ Z,Z,Z Z , Z , Z Z , Z , Z OK OK 'Z','Z','Z' OK OK
23 T=(Y,Z), /**/ Y,Z Y , Z Y , Z OK OK 'Y','Z' OK OK
24 T=(Z,Y), /**/ Z,Y Z , Y Z , Y OK OK 'Z','Y' OK OK
25 write_term(T,[quoted(true),
 variable_names([
  'X'=Z,'X'=Y,'X'=X])]).
_164 _583 _D _23 _3b4 _1.. _G864
26 T=(X,Y,Z), /**/ X , X , X X , X , X X,X,X X,X,X 'X','X','X' X,X,X X,X,X
27 T=(1,2,3), T=(X,Y,Z), /**/ 1 , 2 , 3 1 , 2 , 3 1,2,3 1,2,3 1,2,3 1,2,3 1,2,3
32 read_term(T,[
 variable_names(VN_list)]),
VN_list=[_=1,_=2,_=3],
writeq(VN_list).
29 /**/ B+C+A+B+C+A. any perm. ['B'=1,'C'=2,'A'=3] ['B'=1,'C'=2,'A'=3] ['A'=1,'B'=2,'C'=3] ['B'=1,'C'=2,'A'=3] ['A'=1,'C'=2,'B'=3] ['B'=1,'C'=2,'A'=3] ['B'=1,'C'=2,'A'=3] ['A'=1,'B'=2,'C'=3]
30 write_term(T,
 [variable_names(VN_list)]).
_164 loops inst._e. _26 inst._e. _131777 inst._e.
31 VN_list = 1, /**/ _168 _707 ty._e.(list,1) do._e.(write_o.,v._n(..)) wrong_coll. _131821 ty._e.(list,1)
33 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.
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).

Version Control, Validated HTML