I figured it out. You need the immex phrase when you want to run the repl
from the command line.
Otherwise, J continues to read input from the file rather than from stdin.

BTW, I don't want to spam the lists with these videos I'm making every day,
but this one in particular might be interesting to some of you who already
know J:

I'm working on a console mode REPL for J with syntax highlighting, but also
"time-travelling" - the ability to roll back output and undo assignments.

Today's episode (of the Ridiculously Early J Morning Show) explains how it
works:

https://www.youtube.com/watch?v=zja1b-xadXg&list=PLMVwLeG3bKmmctpRZt7u7hL8d82Jr1Av4&index=6





On Fri, Sep 3, 2021 at 7:09 AM Michal Wallace <[email protected]>
wrote:

> Over the years I've known J, the question of how to make J implement a
> repl / input loop has come up numerous times.
>
> Back in 2014, I sat down and figured out how to make one:
>
> NB. -----------------------------------------
> readln =: [: (1!:01) 1:
> donext =: [: (9!:29) 1: [ 9!:27
> main =: verb define
>    echo ''
>   echo 'main loop. type ''bye'' to exit.'
>    echo '--------------------------------'
>    while. (s:'`bye') ~: s:<input=:readln'' do.
>     echo ".input
>    end.
>   echo '--------------------------------'
>   echo 'loop complete. returning to j.'
>   NB. or put ( exit'' ) here to exit j.
> )
> donext 'main _'
> NB. -----------------------------------------
>
> And since then, numerous people have asked how to do this because it was
> presumably a hard thing to do, and I would always point them to this
> example.
>
> Yesterday on stream I was talking about making a REPL, and saw it's now
> possible to just put the readln ((1!:1)1) call in a loop:
>
> NB. -----------------------------------------
>
> repl =: {{
>
> src =. ''
>
> while. 1 do.
>
> src =. CRLF -.~ 1!:1]1 NB. readline
>
> if. src -: 'bye' do. 0$0 return. end.
>
> res =. ". src
>
> echo res
>
> end. }}
> NB. -----------------------------------------
>
> Am I crazy to think this used to be difficult?
>
> If not, what changed, and when?
>
> -Michal
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to