didoudiaz / gprolog

GNU Prolog
Other
106 stars 13 forks source link

Likely simple bugs to fix in the format/2-3 predicates #37

Closed pmoura closed 1 year ago

pmoura commented 1 year ago

Bug in the implementation of ~c (code): the following calls are expected to print an A:

| ?- format("~c", [65]).

yes
| ?- format('~c', [65]).

yes

Bug in the implementation of ~i (ignore): the following calls are expected to omit the middle argument and thus print ac:

| ?- format("~a~i~a", [a,b,c]).
ab

yes
| ?- format('~a~i~a', [a,b,c]).
ab

yes
spabreu commented 1 year ago

Hi Paulo,

Bug in the implementation of ~c (code): the following calls are expected to print an A: | ?- format("~c", [65]).

yes | ?- format('~c', [65]).

yes

In this case, I don’t think there's a bug:

| ?- format("~c", [65]), flush_output. A

yes

cheers, -spa

pmoura commented 1 year ago

Hi Salvador.

Interesting. But other Prolog systems don't require a call to flush_output/0 (or flush_output/1 for format/3 calls).

pmoura commented 1 year ago

Additionally, the test definition implicitly closes the output stream, which is expected to flush any pending output.

pmoura commented 1 year ago

Fixes confirmed. Thanks!