[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] FilePlugin>>primitiveFileAtEnd for non-regular files (#232)

David T. Lewis lewis at mail.msen.com
Sun Apr 1 20:08:27 UTC 2018


On Sun, Apr 01, 2018 at 12:26:56PM -0700, Nicolas Cellier wrote:
>  
> Hi Alistair,
> OK, I see your point, my proposal would work for /dev/random but maybe not all possible kind of stream
> But then primitiveFileAtEnd is trying to be too smart:
> - being able to test atEnd in pre-condition for regular files
> - being able to test atEnd in post-condition for the rest of the world (pipe socket special devices etc...).
> It's kind of brainfuck. I say we should simplify and keep only one, post-condition with a simple feof and leave smartness at image side.
> What if we add
> 
>     primitiveEncounteredEndOfFile
>         "Answer true if the end of file was encountered at last read operation".
> 
> And leave current primitive only for backward compatibility with deprecation warning in the comment?
>

As a point of reference, in OSProcess it is implemented as StandardFileStream>>atEndOfFile
as an extension in *OSProcess-Base, as distinct from StandardFileStream>>atEnd. The EOF
test is done in the OSProcessPlugin (not FilePlugin), and is implemented as #primitiveTestEndOfFileFlag.

The most important use case is for a file stream on an OS pipe (e.g. OSPipe new reader).

Similar to /dev/random, the stream on an OS pipe is represented as a kind of
PositionableStream, but it is a positionable stream that does not know its
position, and for which the position is not settable.

I do not know of a perfect solution to this, but if you want to experiment on
the image side with the different semantics of "at end now" versus "last operation
hit the EOF condition so do not bother asking for more" then the primitiveTestEndOfFileFlag
that is present in any VM with the UnixOSProcessPlugin will probably give you
what is needed to try out some new ideas.

Dave
 


More information about the Vm-dev mailing list