scryer-prolog
scryer-prolog copied to clipboard
Missing resource error
?- length(_,L), open('/dev/null',read,S).
L = 0, S = '$stream'(0x5644c5b819a8)
; L = 1, S = '$stream'(0x5644c5b84f68)
; ...
; L = 1013, S = '$stream'(0x5644c5a06218)
; L = 1014, S = '$stream'(0x5644c5a06288)
; caught: error(syntax_error(input_output_error),open/4) % unexpected
Where is the wrong syntax? There is none. There is no Prolog text which could cause a syntax error.
What should happen in this case is a resource error. Just as NOTE 3 of 8 elaborates:
3 The use of any built-in predicate (and particularly those concerned with input/output - 8.11, 8.12, 8.13, 8.14) may cause a Resource Error (7.12.2 h) because, for example, the program has opened too many streams, or a file or disk is full. The use of these built-in predicates may also cause a System Error (7.12.2 j) because the operating system is reporting a problem.
And open/3 is 8.11.5.
Related: #1374.
Now:
target/release/scryer-prolog -f
?- use_module(library(lists)).
true.
?- length(_,L), open('/dev/null',read,S).
L = 0, S = '$stream'(0x5641b72a1b28)
; L = 1, S = '$stream'(0x5641b72bbae8)
; ...
; ; L = 1009, S = '$stream'(0x5641b73f5708)
; error(syntax_error(input_output_error),open/4), unexpected.
...
; resource_error(_). % expected
input_output_error is no syntactical issue at all.
UWN_non-conformance
?- length(_,L), open('/dev/null',read,S).
L = 0, S = '$stream'(0x5641c8033b28)
; L = 1, S = '$stream'(0x5641c804b578)
; L = 2, S = '$stream'(0x5641c7e69bd8)
; L = 1007, S = '$stream'(0x5641c80679c8)
; error(resource_atom(out_of_files),open/4), unexpected.
...
; resource_error(file_descriptors). % or whatever else is a good name for that resource