A programming convention

Ulf Wiger etxuwig@REDACTED
Tue Jun 11 09:01:46 CEST 2002


On Tue, 11 Jun 2002, Joe Armstrong wrote:

>Without the Q the function must work. The relationship is
>obvious
>
>	lookup(Key, Dict) ->
>	    case (catch lookupQ(Key, Dict)) of
>		{'EXIT', Why} ->
>			{error, Why};
>		Other ->
>			{ok, Other}
>	    end.

...Obvious, but (obviously) the opposite of the above. ;)

   lookupQ(Key, Dict) ->
      case (catch lookup(Key, Dict)) of
         {'EXIT', Why} ->
            {error, Why};
         Other ->
            {ok, Other}
      end.


>We also say that functions with a Q at the end of the name *always*
>return maybe() types << maybe() = {ok, Val} | {error, Why} >>
>
>If we do all this we will *finally* be able to define an error
>in a program as a "top level untrapped exit"
>
>Comments welcome


I don't have any objections. If there is a better alternative
than a 'Q' suffix, I can't think of it right now.

/Uffe
-- 
Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson Telecom AB, ATM Multiservice Networks




More information about the erlang-questions mailing list