[erlang-questions] lists:keyfind as an alternative to lists:keysearch

Bjorn Gustavsson bgustavsson@REDACTED
Wed Jan 21 14:22:40 CET 2009


On Wed, Jan 21, 2009 at 12:44 PM, Richard Carlsson <richardc@REDACTED> wrote:
>
> I  tried to narrow it down to just one alternative suggestion, and
> {ok,Value}|'error' is the convention used by dict:find. It seems
> to depend on what you read into the name of the function: if the
> name is "find" or "keyfind", aren't you expecting it to find the
> element? You didn't use the "lookforsomethingthatmightnotbethere"
> function. Anyhow, I wouldn't have suggested 'error' unless there
> was some precedence for it. I prefer 'none' or 'not_found' for
> this kind of return value, but consistency is also a good thing
> (so maybe 'false' is still best).
>

For consistency with the rest of the lists module (and in particular
the keysearch/3 function) I think that 'false' is the best value.

(In general, I agree that "half booleans" should be avoided
in new code.)

/Bjorn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list