Hi,
this is due to 'return' (\n) which ends the read(X) and remains in the
keyboard buffer - when the first solution of name (bob) is displayed,
the return is send to the top-level which ends the alternatives.
To consume the return, you can use:
| ?- read(Y), get_char(_), name(X).
Daniel
Le 08/01/2023 à 16:46, one_of_us a écrit :
o@Kiki:~/prolog/gen_rythm$ uname -a
Linux Kiki 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21)
x86_64 GNU/Linux
o@Kiki:~/prolog/gen_rythm$ gprolog
GNU Prolog 1.4.5 (64 bits)
Compiled Feb 23 2020, 20:14:50 with gcc
By Daniel Diaz
Copyright (C) 1999-2020 Daniel Diaz
| ?- [user].
compiling user for byte code...
name(bob).
name(ann).
name(joe).
end_of_file.
user compiled, 3 lines read - 292 bytes written, 45418 ms
yes
| ?- name(X). %
%
X = bob ? ; % Here is possibility
% to request another
X = ann ? ; % solutions.
% It is good.
X = joe %
yes
| ?- read(Y), name(X). %
tratata. % Here is not such possibility.
% Why?
X = bob % Is it a bug?
Y = tratata ? %
yes
| ?-