Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.prolog > #14862
| From | Mild Shock <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.prolog |
| Subject | How to make a tag variable an attributed variable (Was: SWI-Prolog as the gravity of all: Dream Big / Dream Standard) |
| Date | 2025-09-28 14:41 +0200 |
| Message-ID | <10bbaeg$73l4$1@solani.org> (permalink) |
| References | (2 earlier) <10b9b4m$1glk8$1@dont-email.me> <10bajqs$6lfr$1@solani.org> <10bakaq$6lp1$1@solani.org> <10baklu$6lrs$1@solani.org> <10baljm$6mfk$1@solani.org> |
Hi,
You can still make a tag variable an
attributed variable in SWI-Prolog. This
here works in SWI-Prolog:
?- X = foo{bar:123,baz:abc},
freeze(Tag, Tag = foo),
Y = Tag{bar:Value1,baz:Value2}, X = Y.
X = Y, Y = foo{bar:123, baz:abc},
Tag = foo,
Value1 = 123,
Value2 = abc.
?- X = foo{bar:123,baz:abc},
freeze(Tag, Tag = jack),
Y = Tag{bar:Value1,baz:Value2}, X = Y.
false.
But if the tag variable is an attributed
variable, the write result can possibly
not be read back:
?- freeze(X, X = foo), Y = X{bar:123,baz:abc},
write_term(Y, [attributes(dots)]).
_9352{...}{bar:123,baz:abc}
Y = X{bar:123, baz:abc},
freeze(X, X=foo).
The syntax of cascaded dicts, is not supported,
the Tag can only be atomic or variable, but
not structured itself at the moment:
?- X = foo{bar:123}{baz:abc}.
ERROR: Syntax error: Operator expected
ERROR: X = foo{bar:123
ERROR: ** here **
ERROR: }{baz:abc} .
The old and existing proposals that have dict
syntax only for attributed variable state, typically
avoid a cascading syntax.
Bye
Back to comp.lang.prolog | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How SWI-Prolog went down hills Mild Shock <janburse@fastmail.fm> - 2025-09-27 19:50 +0200
Re: Julio Di Egidio has never heard of unification (Was: How SWI-Prolog went down hills) Julio Di Egidio <julio@diegidio.name> - 2025-09-27 20:41 +0200
The PoC (Proof of Concept) aspect of a PIP (Was: Julio Di Egidio has never heard of unification) Mild Shock <janburse@fastmail.fm> - 2025-09-28 08:15 +0200
Help! We need Boris the Loris, its all Fuzzy (Was: The PoC (Proof of Concept) aspect of a PIP) Mild Shock <janburse@fastmail.fm> - 2025-09-28 08:24 +0200
My Citation Source : SWI-Prolog discourse (Was: Help! We need Boris the Loris, its all Fuzzy) Mild Shock <janburse@fastmail.fm> - 2025-09-28 08:30 +0200
SWI-Prolog as the gravity of all: Dream Big / Dream Standard (Was: My Citation Source : SWI-Prolog discourse) Mild Shock <janburse@fastmail.fm> - 2025-09-28 08:46 +0200
How to make a tag variable an attributed variable (Was: SWI-Prolog as the gravity of all: Dream Big / Dream Standard) Mild Shock <janburse@fastmail.fm> - 2025-09-28 14:41 +0200
Julio Di Egidio has never heard of unification (Was: How SWI-Prolog went down hills) Mild Shock <janburse@fastmail.fm> - 2025-09-27 20:10 +0200
csiph-web