ichiban / prolog

The only reasonable scripting engine for Go.
MIT License
620 stars 31 forks source link

Unexpected domain error #253

Closed UWN closed 2 years ago

UWN commented 2 years ago
?- [user].
2022/09/10 17:14:10 error(domain_error(source_sink,user),consult/1)

why is this a domain error? Rather an existence error like in open/3.

ichiban commented 2 years ago

This was simply my mistake. Fixed in v0.11.1

$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v0.11.1
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- [foo].
2022/09/19 12:53:50 error(existence_error(source_sink,foo),consult/1)
?- 

Regarding the special file name user, @guregu's consult/1 should be able to support it because it abstracts the file system for read: https://github.com/guregu/predicates/blob/8d1f2312c236dd1dd3dbc92f3fb20263e2136c80/fs.go#L161

Also, there's a Go proposal to fully abstract file systems https://github.com/golang/go/issues/45757