Is this a known limitation or a bug or some stupidity on my part? If
it's something with racket, do you guys know of any workaround? I plan
on making a read-line wrapper that checks to see if the first attempt
is an empty line and if so, calls read-line again taking whatever it's
result is, but I'd rather live without those hacks if at all possible.
Am I missing some sort of configuration for the REPL?
Thanks,
Alexandre Moreira.
--
"Bad programming is easy. Idiots can learn it in 21 days, even if they
are dummies."
- As seen in 'How to Design Programs'
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
A known limitation. The REPL implemented by plain `racket' does not
separate the input stream for REPL expressions from the program's input
stream.
> If it's something with racket, do you guys know of any workaround?
DrRacket splits the expression and program-input streams, as Jos has
noted.
Offhand, I'm not aware of a tool that similarly splits input streams
within a terminal.
You could try to call (read-line) twice and see if the secone one
returns what you want. This would confirm your suspicions,
-- hendrik
On Thu, Jan 6, 2011 at 8:00 PM, Hendrik Boom <hen...@topoi.pooq.com> wrote:
> On Thu, Jan 06, 2011 at 04:09:49PM -0200, Alexandre Moreira wrote:
>> Hello, everyone. I'm trying to use the (read-line) function in
>> racket's REPL and I'm having a weird problem. Whenever I type
>> (read-line) in the REPL prompt it returns the empty string. It's as if
>> it is receiving the linefeed character I use to enter the command on
>> the REPL.
>
> You could try to call (read-line) twice and see if the secone one
> returns what you want. This would confirm your suspicions,
Hendrik, I already do that. My workaround so far is to write a functon
somewhat like this
(define (my-read-line)
(let ([contents (read-line)])
(if (string=? contents "")
(read-line)
contents)))
It works, but it's kinda annoying to need that.
>
> -- hendrik
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>
--
"Bad programming is easy. Idiots can learn it in 21 days, even if they
are dummies."
- As seen in 'How to Design Programs'
> -----Original Message-----
> From: users-...@racket-lang.org
> [mailto:users-...@racket-lang.org] On Behalf Of Hendrik Boom
> Sent: 06 January 2011 23:01
> To: us...@racket-lang.org
> Subject: Re: [racket] REPL and read-line
>
What additional functionality do you need beyond in your shell beyond
the REPL? Why not just type commands into the REPL directly? I'm a bit
confused by this use case. If you expand on it perhaps we can come up
with an alternative.
N.
I wonder if it'd be easy (and not break anything) to make the REPL
consume whitespaces between datums.
As of now I they are working with the hack I posted before: The only
problem is that at times, if the user truly wants to give a blank
line, he needs to press enter twice.
On Fri, Jan 7, 2011 at 8:32 AM, Noel Welsh <noel...@gmail.com> wrote:
> On Fri, Jan 7, 2011 at 2:01 AM, Alexandre Moreira <alexa...@gmail.com> wrote:
>> Thanks everyone for your responses. Unfortunately I planned on using
>> the REPL as a kind of shell for a little utility I need, so I guess
>> I'll only have to live with it.
>
> What additional functionality do you need beyond in your shell beyond
> the REPL? Why not just type commands into the REPL directly? I'm a bit
> confused by this use case. If you expand on it perhaps we can come up
> with an alternative.
>
> N.
>
--
"Bad programming is easy. Idiots can learn it in 21 days, even if they
are dummies."
- As seen in 'How to Design Programs'
It sounds to me that the big problem is that the behaviour is different
on different systems. If it were consistent either way, you could
adapt?
-- hendrik
Hendrik, the only problem is that I find it unlikely that a consistent
behaviour can be found without "solving" the problem in the first
place (that is, making it so that my kind of hack is not needed).
Because there's (as far as I can see) a clear reason why the read-line
fails (the newline that is left on the stream after the user enters
one (or more?) datum on the REPL), and it'll ensure that only the
first read-line will fail. To be more precise, not only read-line, any
read-char will also fail and get only the newline.
So, if this char were to be stripped out of the input (but I'm not
sure it's a viable change, nor if it'd break more things that depend
on the behaviour), no workaround would be necessary, if it's not
stripped, it's pretty much impossible to change it the otherway so
that it'll always be there.
Please, don't think that by these messages I'm implying that something
"should be done" in racket or anything like that. I only want to
understand what the limitations are so I can decide on how to act on
them in my app. Considering English is not my main idiom, I might be
sounding more rude than I mean to.
>
> -- hendrik
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>
--
"Bad programming is easy. Idiots can learn it in 21 days, even if they
are dummies."
- As seen in 'How to Design Programs'