[erlang-questions] Package Support/Use

Thomas Lindgren <>
Mon Nov 6 14:52:27 CET 2006



--- "Ulf Wiger (TN/EAB)" <>
wrote:

> The problem with the latter is that if your function
> contains several of
> those constructs, say:
> 
> 
> read_data() ->
>    {ok, Bin_a} = file:read_file("a"),
>    {ok, Bin_b} = file:read_file("b"),
>    {ok, Bin_c} = file:read_file("c"),
>    [Bin_a, Bin_b, Bin_c].
> 
> and you get an exit with {badmatch, {error,
> enoent}}, you're lost
> regarding what particular line caused the error,
> unless the Reason part
> is unique for all constructs.

The underlying problem here is that the standard
exceptions are uninformative to the point of
uselessness. 

If the compiler instead would generate something like
smart exceptions (which is, alas, at best a partial
solution; see jungerl), which also include information
about module, line, arguments, etc., then that problem
would go away. Or, if I can dream, one could do even
better with some support from the VM.

Regarding exceptions vs tagged tuples, I theoretically
prefer exceptions but have found that I often need to
use tagged tuples in practice. If I instead will have
to wrap calls in catch to figure out and handle
(usually undocumented) exception values, not a
terrible lot has been gained.

Best,
Thomas




 
____________________________________________________________________________________
Sponsored Link

Free Uniden 5.8GHz Phone System with Packet8 Internet Phone Service
http://www.getpacket8.net/yahoo2



More information about the erlang-questions mailing list