But you cannot "observe" waiting at the receiving
end of a stream. With or without wait shouldn't
make a difference in the result.
If you have a stream 'abc<wait>def'
and a stream 'abcdef'
There is absolutely no observable difference
for what parsing should do. I still think
you are halucinating and confused.
The standard says:
3.160 source. A pysical object from which a
processor **inputs data**, for example a file,
terminal, or interprocess communication channel.
But there is no <wait> input data. Can you show
me any code, using only ISO core standard means,
that would detect <wait> input data?
This is impossible because there is no <wait>
input data. This is something that is business of
the source when it produces input data,
but the input data is free of any <wait>. What
is the byte code of <wait> or the character code
of <wait>? This is complete nonsense,
there is no such byte code or character code.
All you will see is the following:
- For peek_byte/[1,2], etc.., input n-bytes stream,
with after n-th byte there is EOF.
- For peek_code/[1,2] and peek_char/[1,2], etc..
input n-characters stream, with after n-th character
there is EOF.
You cannot see anything else in input data
regularly. Only if you would have a peek_avail/1,
which would return some info if the stream is
waiting. But there is no such API.
You confuse the input data with the source.
The input data is not the source. The source can
be file, terminal or interproicess communication
channel, but the input data
is still binary stream or text stream. And these
streams presently have no peek_avail/1 API. You
can only notice <wait> went your streams provide
this information through their input data APIs.
Such an API is for example found in other Programming
Languages and Runtimes. But I don't see any such
API in the Prolog ISO core standard. It could be
helpful to code top-levels, but the binary
and text streams of the ISO core standard don't
provide it. What is missing in the ISO core standard,
and what might be even not supported by all
streams is the following:
"Returns an estimate of the number of bytes that can be read
(or skipped over) from this input stream without blocking by
the next invocation of a method for this input stream. The
next invocation might be the same thread or another thread.
A single read or skip of this many bytes will not block,
but may read or skip fewer bytes."
https://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html#available%28%29
Thats even not a very health API, since it may
support polly loops programing style. A much better
API would be some that would use some async mechanism.
Its good that this didn't find its way into ISO core
standard. So definitely in ISO core standard there
is absolutely no notion of <wait>. Thats just a
halucination and confusion of yours. A wait inside
a source has nothing to do with the produced
input data. A Prolog system might have available() or
something similar and even use it somewhere, but this
has nothing to do with the ISO core standard. You
can test all read/write as if the input came from
a file, without any blocking in the source. One
way to do this easily is with_input_from/2 where the
file is replaced by a memory stream. So to allow
easy harnessing of small test cases,
but there is definitely no recognizable <wait>
in input data in ISO core standard.