current-read-interaction is documented as:
(current-read-interaction) → (any/c input-port? -> any) (current-read-interaction proc) → void? proc : (any/c input-port? -> any)
A parameter that determines the current read interaction handler, which is procedure that takes an arbitrary value and an input port and returns an expression read from the input port.
The default read interaction handler accepts src and in and returns
(parameterize ([read-accept-reader #t] [read-accept-lang #f]) (read-syntax src in))
From this I expect it will not return until/unless it has read an expression to return.
At most, I expect it might return a value satisfying eof-object?
once --- when the input port has reached eof, for example the user pressed Ctrl-d
. Which I handle by exiting the REPL.
And that works as expected for most readers. If there's an expression to return, they return it. If one isn't available, yet, they don't return, yet.
However starting with #lang datalog
, and now also with #lang rhombus
, I am seeing eof
being returned more often, such as for input like "\n"
, and/or as a kind of "expression delimiter".
This is surprising and confusing. I am not sure what to do about it. Should I ignore eof completely, losing the ability of the user to exit via Ctrl-D
?
Probably I'm being dense, but I genuinely don't understand the "use case" for returning eof to mean "no expression available, yet". Why not just... not return, yet? Can someone help me understand the motivation? Could maybe a distinct value could be returned for that case (instead of "overloading" eof
), which I could test for and take whatever action is documented for that value?