# Current-read-interaction returning eof

**URL:** <https://racket.discourse.group/t/current-read-interaction-returning-eof/1032>\
**Category:** Questions & Answers\
**Tags:** repl, rhombus, datalog\
**Created:** [May 26, 2022, 5:06pm UTC](https://racket.discourse.group/t/current-read-interaction-returning-eof/1032 "2022-05-26T17:06:23Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [May 26, 2022, 5:06pm UTC](https://racket.discourse.group/t/current-read-interaction-returning-eof/1032/1 "2022-05-26T17:06:23Z")

</div>

[current-read-interaction](https://docs.racket-lang.org/reference/eval.html#%28def._%28%28quote._~23~25kernel%29._current-read-interaction%29%29) is documented as:

> ```scheme
> (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
> 
> ```scheme
> (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`](https://github.com/racket/datalog/issues/13), and [now also with `#lang rhombus`](https://github.com/greghendershott/racket-mode/issues/621), 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?

---

_[View the full topic](https://racket.discourse.group/t/current-read-interaction-returning-eof/1032)._
