[erlang-questions] A problem with smart_exceptions

YAMASHINA Hio <>
Fri Jun 15 08:34:04 CEST 2007


Hi.

By default, smart_exceptions uses catch expression
for compable with R9. It discard information whether
expression is throw-ed or not.

To make it use try expression, uncomment `r10' definition
at start of smart_comment.erl:

%% define r10 means 'try' is used in the generated code rather
%% than 'catch'. Note that try is _handled_ by default.
%% -define(r10, true).

But described also:
%% - R10B compatibility is weak, not very tested


On Fri, 15 Jun 2007 15:01:12 +0900
"Mikage Sawatari" <> wrote:

> Hello,
> 
> I encountered a problem when I used smart_exceptions in the
> jungerl on Erlang R11B-5. Is there any work around for this?
> 
> 
> 
> A way to reproduce:
> 
> 1. Install the smart_exception at:
>    http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/smart_exceptions/
> 
> 2. Compile the following code:
> 
> ---- exception.erl ----
> 
> -module(exception).
> -export([test/0]).
> 
> test() ->
>         try
>                 test2()
>         catch
>                 Ex -> io:format("Catch ~p~n", [Ex])
>         end.
> 
> test2() ->
>         throw(exception),
>         io:format("throwed exception~n").
> 
> ---- exception.erl ----
> 
> 
> 
> Phenomenon:
> 
> The result differs depending on whether we use smart_exception or not.
> 
> $ erlc +'{parse_transform, smart_exceptions}' exception.erl && erl
> -noshell -s exception test -s init stop
> throwed exception
> 
> $ erlc exception.erl && erl -noshell -s exception test -s init stop
> Catch exception
> 
> It seems when the smart_exception is in effect, "throw" statement
> isn't executed and the computation falls through the next line.
> 
> 
> -- 
> -----------------------------------------------------------------------
> SAWATARI Mikage (SANO Taku)
> http://www.mikage.to/
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions


-- 
YAMASHINA Hio <>




More information about the erlang-questions mailing list