scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Missing resource error

Open UWN opened this issue 3 years ago • 1 comments

?- 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.

UWN avatar Mar 27 '22 18:03 UWN

Related: #1374.

triska avatar Mar 27 '22 18:03 triska

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 avatar Mar 27 '23 07:03 UWN

UWN_non-conformance

UWN avatar Sep 20 '23 10:09 UWN

?- 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

UWN avatar Sep 23 '23 07:09 UWN