Closed UWN closed 1 year ago
... and sometimes I have to wait even longer...
It's not simply slow but requires 4 extra lines to complete the read. It could be a bug in 1pl
.
?- read(X), read(Y).
|: foo.
|: bar.
|:
|:
|:
|:
X = foo,
Y = bar.
I found the cause of the bug. This Peek(5)
to detect end_of_stream
blocks and requires 4 extra bytes in input.
Currently:
ulrich@p0:/opt/gupu/ichiban-prolog$ git log -1
commit b77736e7da6b040582bbb2aa5946d04fb6ade010
Merge: b8ca24c 5970281
Author: Yutaka Ichibangase <yichiban@gmail.com>
Date: Sat Jul 22 18:20:08 2023 +0900
I fixed the bug and it doesn't wait for extra bytes in v1.1.3
.
$ go install github.com/ichiban/prolog/cmd/1pl@latest
go: downloading github.com/ichiban/prolog v1.1.3
$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v1.1.3
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- read(X),X.
|: write(ok),nl.
ok
X = write(ok),nl.
?-
in this case
read/1
does not succeed immediately after receiving the first return, but wait for further input, after a couple of returns it finalle succeeded.read/1
must succeed immediately after reading the first return, actually after reading .return since this is unambiguously the end token.