[erlang-questions] Package Support/Use

Mats Cronqvist mats.cronqvist@REDACTED
Mon Nov 6 14:41:30 CET 2006

Christian S wrote:

>> >   {ok,FD} = open(Name),
>> >   {ok,Data} = read(FD),
>> >   {ok,PD} = process_data(Data),
> I dont mind intermediate variables at all when they can be given useful 
> names,
> I find that they double as comments then. Plus,... I type faster than
> I code. 

   in BettErl you could of course write;
  FD = open(Name),
  Data = read(FD),
  PD = process_data(Data),

> The fact that badmatch exceptions have less information
> (source location!) than one would desire is unfortunate (not
> changeable due to backwards compat?).

   see smart_exceptions (in jungerl) by Thomas Lindgren.
   i don't know if there is a good reason not to include this in OTP. performance?

> As for what is truly exceptional and what isn't: I think it is the
> choice of the programmer to pick what "story" he/she wants to present:

   i see it as "exception" (a case that does not conform to a rule or 
generalization), not "exceptional" (extraordinary). e.g. if i read 1,000 bytes 
from a file, it is not exceptional that i get an eof, but it is an exception. 
hence file:read/2 should return data or throw.
   e.g. to fold over 1,000 byte blocks;

fold(FD,Fun,Acc) ->
  try fold(FD,Fun,Fun(file:read(FD,1000),Acc))
  catch eof -> Acc

> I reject neither exceptions nor tagged tuples, I want both as options
> in the standard libraries.

  <confused> two versions of each function?


More information about the erlang-questions mailing list