ok or true? (fwd)

Fredrik Linder fredrik.linder@REDACTED
Mon Feb 23 13:43:29 CET 2004


> -----Original Message-----
> From: Ulf Wiger
> Sent: den 23 februari 2004 13:11
> 
> On Mon, 23 Feb 2004 12:45:44 +0100 (MET), Kostis Sagonas 
> <kostis@REDACTED> wrote:
> 
> > Thomas Lindgren <thomasl_erlang@REDACTED> wrote:
> >  >
> >  > > In general you should stick to regular return values
> >  > > like
> >  > >
> >  > >     {ok, Val} | {error, Why}
> >  > >
> >  > >     {value, V} | error
> >  > >
> >  > > for the same reason
> >  >
> >  > Case in point:
> >  >
> >  >       lists:keysearch -> {value,X} | false
> >  >
> >  > Argh. Oh well, one can always wrap such madness.
> >
> > I guess list:keysearch HAS to wrap its result, so that it can
> > also return the atom 'false' or 'error' or anything similar.
> 
> Yes, but then
> 
>    {found, Value} | not_found
> 
> would have been better, or (debatable)
> 
>    {true, Value} | false.
> 
> /Uffe

Or why not use true|false whenever there is a yes/no-style reply, and either {value,Value}|undefined or Value|exit(undefined) when a value is returned.

/Fredrik



More information about the erlang-questions mailing list