Re: In-source documentation pre-SRFI draft #2
Antero Mejr 29 May 2024 02:09 UTC
"Arthur A. Gleckler" <xxxxxx@speechcode.com> writes:
> On Tue, May 28, 2024 at 5:12 PM Antero Mejr <xxxxxx@antr.me> wrote:
>
> (read-doc port)
> => documentation record
> attached = #f
> text = " Note: the answer should be five. "
> content = #f
>
> Shouldn't content be eof-object? If it's #false, you won't be able to
> distinguish the last case from "#false" appearing in the input stream.
The last documentation comment uses #|? ... ?|#, which means it is
unattached (see the attached = #f field in the record). So the content
field will always be #f, because there is no content. After reading that
unattached record, then the eof-object will be read, because the port is
exhausted.
Attached documentation comments cannot appear at the end, so their
content will not be eof-object either. The spec says:
An exception should be raised [by read-documentation] if an attached
documentation comment is read, but there are no more objects to read
before the expression ends or the port is exhausted.