[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gets ambiguity and enum suggestion
Smelly Pooh <plop+goo@redbrick.dcu.ie> writes:
> Version .146
>
> The gets method returns an empty string "" whether we're at EOF or
> reading an empty line,
gets is defined to return a <str>. the protocol is set up to require
that the user call eof? to disambiguate these cases.
> peek never seems to return EOF and I don't want to mix get with gets
> calls.
>
> There also seems to be a bug when calling peek just before and after EOF
> is returned by get. Each time peek is called #\ is returned, then
> calling get on the port also returns #\ instead of EOF
i'm not sure why this is from looking at the implementation:
src/goo/io/port.goo and src/goo/io/%port.c
it would seem peek should return ``(eof-object)'' based on its
``fgetc'' implementation. it is merely a wrapper for ``fgetc'' and
``ungetc''. are you running on windows or linux?
> On the topic of the enum method, can it be made to be more generic than
> taking <col> as its first argument? That would allow types such as
> <port> to work with the enum protocol, and simplify cases where people
> want to create enums, but not necessarily a full fledged collection
i'm sympathetic. i'll respond more fully to your next message.
jonathan