Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_n_chars/3 hangs #662

Open
flexoron opened this issue Jan 24, 2025 · 0 comments
Open

get_n_chars/3 hangs #662

flexoron opened this issue Jan 24, 2025 · 0 comments

Comments

@flexoron
Copy link

flexoron commented Jan 24, 2025

Scryer (for comparsion)
$ scryer-prolog -f
?- use_module(library(charsio)).
?- use_module(library(format)).
?- use_module(library(between)).
?- between(0,3,M),(M<3->N=M;N=4),get_n_chars(user_input,N,C),format("<~s>",[C]),writeq(C),nl,fail.
abcdef
<>[]
<a>[a]
<bc>[b,c]
<def
>[d,e,f,'\n']  % N=4 to get the newline, too
   false.
?- halt.

$ tpl  # v2.63.33
?- use_module(library(charsio)).
?- between(0,3,M),(M<3->N=M;N=4),get_n_chars(user_input,N,C),format("<~s>",[C]),writeq(C),nl,fail.
abcdef
% Hangs
% now ^D 
<abcdef             % unexpected
>[a,b,c,d,e,f,'\n'] % unexpected
% Hangs
% now ^D^D (twice)
false
?-

It happens because it starts with N = 0.

?- get_n_chars(user_input,0,C), length(C,N).
<Return>
   C = "\n", N = 1. % unexpected, parameter requests  0 chars.
?- 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant