A programming convention

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Tue Jun 11 13:07:17 CEST 2002


I think it would be very helpful if such a convention would be established 
and used (nonetheless in OTP)!

>   maybe() ::= {value, X} | none
>For situations where I know that something might not have a value and I'll
>make no attempt at handling the unexpected behaviour.

I'm not sure if it is really an 'unexpected' behaviour... after all, both 
the function's implementor and user need to plan for it happening.

>         might() ::= {ok, Value} | {error, Why}
>For situations where I know that something might not work and I may wish
>to handle the unexpected behaviour. Example handling {error, enofile} in 
>file:open
>
>must() ::= Value | EXIT(Why)
>I require the expected behaviour and want to crash if I cannot continue.

I would like to add another case that is a combination (with an ugly name)
    maybe_or_might() ::= {value, X} | none| {error, Why}
because (taking the example of "lookup") a key search might or might not 
return any value, while during the call the dictionary server might crash 
(or Mnesia gets into an incosistent state, or something).

>I think the *important* thing is that *everybody* uses the standard types
>and NOT their own variants.

I agree completely.

regards,
Vlad

_________________________________________________________________
MSN Foto är det enklaste sättet att dela eller skaffa papperskopior av dina 
foton: http://photos.msn.com/support/worldwide.aspx




More information about the erlang-questions mailing list