Re: [racket-users] regexp-match + REPL leads to confusing output

2019-10-16 Thread Matthew Flatt
At Wed, 16 Oct 2019 21:25:35 +, Sage Gerard wrote:
> I'd like to understand the reader better, and this seems relevant to
> it. In this REPL session I do not escape \S with a second \ in the
> first interaction. After I introduce the slash later, the REPL never
> really "recovers." Even a simple (displayln) stops producing output.
>
> What's happening?

You're stuck inside a string.

The reader sees

 (regexp-match #rx"typedef (\S

and then complains. After complaining, it goes back to reading
expressions. At that point, the input stream still has the unconsumed
characters. Specifically, the next characters are

 +)

so, `+` is read successfully and evaluated, and the result prints
#. Reading again encounters the closing parenthesis by
itself, so that's the next error. But the input stream still has
more...

 " "

Those three characters read ok, and the value prints as " ". The input
stream continues

  typedef void ()

and so on. Your transcript ends with a double quote that is not yet
closed.


DrRacket's interaction area takes a different (and less confusing)
approach than command-line Racket. As soon as there's any kind of error
from reading and evaluating text submitted at a prompt, DrRacket (not
the reader) discards the input stream and starts a fresh stream with
the new prompt.

But as far as the reader goes, the relevant property is that it stops
consuming characters from a stream when it encounters an error.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/5da7a5b8.1c69fb81.b15dd.5858SMTPIN_ADDED_MISSING%40mx.google.com.


[racket-users] regexp-match + REPL leads to confusing output

2019-10-16 Thread Sage Gerard
I'd like to understand the reader better, and this seems relevant to it. In 
this REPL session I do not escape \S with a second \ in the first interaction. 
After I introduce the slash later, the REPL never really "recovers." Even a 
simple (displayln) stops producing output.

What's happening?

Welcome to Racket v7.4.

> (regexp-match #rx"typedef (\S+)" "typedef void ()")

; readline-input:1:14: read-syntax: unknown escape sequence `\S` in string [,bt

;   for context]

#

; readline-input:1:30: read-syntax: unexpected `)` [,bt for context]

" "

; typedef: undefined;

;  cannot reference an identifier before its definition

;   in module: top-level

; [,bt for context]

#

; readline-input:1:47: #%app: missing procedure expression;

;  probably originally (), which is an illegal empty application

;   in: (#%app)

; [,bt for context]

> (regexp-match #rx"typedef (\\S+)" "typedef void ()")

")\n(regexp-match #rx"

; typedef: undefined;

;  cannot reference an identifier before its definition

;   in module: top-level

; [,bt for context]

; |\S+|: undefined;

;  cannot reference an identifier before its definition

;   in module: top-level

; [,bt for context]

" "

~slg

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/wSywBnnCjlkGYj8831CE3ZvQbuMZRAtB3UIz-4hl1yKQiCdQLFVJjm_KXX5qOm0CwHO9YC1Q0y_6wVS8BJu-YNXWFRKe1IwgCiA6v8LPN1s%3D%40sagegerard.com.