ichiban / prolog

The only reasonable scripting engine for Go.
MIT License
564 stars 27 forks source link

Writing operators misses a space #318

Closed UWN closed 2 months ago

UWN commented 3 months ago
?- writeq(1 is X),nl.
1 is_112
X = _112.

Expected: 1 is _112

See 7.10.5 h 1:

... In all cases, a space is output to separate an operator from its argument(s) if any ambiguity could otherwise arise.

Similarly variable_names#73.

ichiban commented 2 months ago

Thank you very much for reporting! Fixed in v1.2.1.

$ go install github.com/ichiban/prolog/cmd/1pl@latest
go: downloading github.com/ichiban/prolog v1.2.1
$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v1.2.1
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- writeq(1 is X),nl.
1 is _79
X = _79.
?- S=(1 is T),N='X',write_term(S,[quoted(true), variable_names([N=T])]),nl.
1 is X
N = 'X',
S = 1 is _90,
T = _90.
?- 
UWN commented 2 months ago

Back to perfect scores!