[racket] raise-ing an exception inside prompt
It looks like prompt installs its own exception handler. So the 3
gets caught and reported by prompt, which then returns a default value
of void and the call to + continues. This bears out with other
examples, such as (list (prompt (raise 3))), which returns a list
containing void.
Carl Eastlund
On Wed, Dec 22, 2010 at 12:28 PM, Keiko Nakata
<keiko at kurims.kyoto-u.ac.jp> wrote:
> I'm not sure if I got your point, as I seem to have the same result
> after replacing with displayln.
>
> My concern is why I get a type error only for the latter?
> (And how I could get both the exception and type error?)
>
> Keiko
>
>
> From: Matthias Felleisen <matthias at ccs.neu.edu>
> Subject: Re: [racket] raise-ing an exception inside prompt
> Date: Wed, 22 Dec 2010 12:15:21 -0500
>
>>
>> Replace print with displayln. (You're buffering the output but it isn't displayed until the repl prints the next prompt.)
>>
>>
>> On Dec 22, 2010, at 11:56 AM, Keiko Nakata wrote:
>>
>> > Hello,
>> >
>> > How should I understand this behavior?
>> >
>> > (with-handlers ([(lambda (_) #t) (lambda (_) (print "exit"))])
>> > (print (+ (prompt (print "hi") (raise 3) (print "bye")) 10)))
>> >
>> > prints "hi" then "exit", whereas
>> >
>> > (+ (prompt (print "hi") (raise 3) (print "bye")) 10)
>> >
>> > prints "hi", then I got an uncaught exception, followed by type error
>> > of adding <void> and 10.
>> >
>> > Btw, where can I find the source code around exceptions,
>> > e.g., raise and with-handlers?
>> >
>> > Thanks,
>> > Keiko