ok or true? (fwd)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ok or true? (fwd)

Fredrik Linder-2
> -----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> wrote:
>
> > Thomas Lindgren <thomasl_erlang> 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