readTermAndReply

Implements read/1,2 and read_term/2,3: parses the next it.unibo.tuprolog.core.Term out of channel (via asTermChannel) and unifies it with arg, failing (not erroring) if the channel has no more terms available.

When lastIsInfoList (i.e. this is a read_term/2,3 call), the last argument is read as a list of variables(_)/variable_names(_)/singletons(_) info requests (via ensuringArgumentIsValidInfoList) and unified with the corresponding read-term metadata; for plain read/1,2, that metadata is discarded.

Throws

if the underlying channel does not support reading terms at all (e.g. JS's not-yet-supported term channels, or a channel closed mid-read).

if the channel's next term is malformed Prolog syntax.