I am reading a file using prolog and was wondering about the difference of saying:
processRead(Stream, ...) :- at_end_of_stream(Stream), !.
and:
processRead(Stream, ...) :- get(Stream, Ch), Ch is -1, !.
Is there any?
First things first! Follow @mat's advice!
If you need to chose,
always prefer using at_end_of_stream/1
over get/2
!
get/2
is deprecated. If you have decade-old legacy code, migrate it.
If your code is new, don't ever use it. Never. Not even once.
at_end_of_stream/1
is defined by the iso-prolog standard.at_end_of_stream/1
—including (but not limited to)
GNU Prolog, SICStus Prolog, SWI Prolog, B-Prolog, and Eclipse CLP.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With