[erlang-questions] try catch params in Core Erlang

Jonas Falkevik jonas.falkevik@REDACTED
Mon Oct 19 10:14:43 CEST 2015


It seems to be the stack trace at least in R16B03-1.

erl source:
-module(test).
-compile(export_all).

test() ->
    try 
	foo:bar()
    catch
        some:thing -> ok;
	error:E ->
	    io:format("third: ~p~n", [E])
    end.

core erlang modification:

@@ -18,10 +18,10 @@
 	      <'some','thing',_cor4> when 'true' ->
 		  'ok'
 	      %% Line 9
-	      <'error',E,_cor5> when 'true' ->
+	      <'error',_E,F> when 'true' ->
 		  %% Line 10
 		  call 'io':'format'
-		      ([116|[104|[105|[114|[100|[58|[32|[126|[112|[126|[110]]]]]]]]]]], [E|[]])
+		      ([116|[104|[105|[114|[100|[58|[32|[126|[112|[126|[110]]]]]]]]]]], [F|[]])
 	      ( <_cor3,_cor2,_cor1> when 'true' ->
 		    primop 'raise'
 			(_cor1, _cor2)



Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
1> c(test, [to_core]).
** Warning: No object file created - nothing loaded **
ok
2> c(test, [from_core]).
{ok,test}
3> test:test().         
third: [[{foo,bar,[],[]},
         {test,test,0,[]},
         {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,573}]},
         {shell,exprs,7,[{file,"shell.erl"},{line,674}]},
         {shell,eval_exprs,7,[{file,"shell.erl"},{line,629}]},
         {shell,eval_loop,3,[{file,"shell.erl"},{line,614}]}]|
        -000000000000000016]
ok

/Jonas

On Oct 15, 2015, at 19:57 , Vladimir Gordeev wrote:

> If you compile some try-catch statements into Core Erlang, you may notice,
> that it receives three params in exception pattern: http://tryerl.seriyps.ru/#id=3bf3
> 
> this:
> 
>     try foo:bar()
>     catch
>         some:thing -> ok
>     end.
> 
> into this:
> 
> 	try
> 	    call 'foo':'bar'
> 		()
> 	of <_cor0> ->
> 	    _cor0
> 	catch <_cor3,_cor2,_cor1> ->
> 	    case <_cor3,_cor2,_cor1> of
> 	      %% Line 7
> 	      <'some','thing',_cor4> when 'true' ->
> 		  'ok'
> 	      ( <_cor3,_cor2,_cor1> when 'true' ->
> 		    primop 'raise'
> 			(_cor1, _cor2)
> 		-| ['compiler_generated'] )
> 	    end
> 
> In "An introduction to Core Erlang" catch described as taking two params: http://www.erlang.org/workshop/carlsson.ps
> 
> Question is: what is this third param (_cor4) for?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151019/263eb3d5/attachment.htm>


More information about the erlang-questions mailing list