ok or true? (fwd)

Joe Armstrong joe@REDACTED
Mon Feb 23 13:24:43 CET 2004


>  > Case in point:
>  > 
>  >       lists:keysearch -> {value,X} | false
>  > 
>  > Argh. Oh well, one can always wrap such madness.



  Youch - this violates the principle of least surprise.

  If you  place you thumb over  the "{value,X}" return  value and only
expose the "false" branch then say:

  - "guess what the other return value is"

  most  sane people  will say  "true" when  shown that  it is  in fact
"{value, X}" the poor unsuspecting programmer will doubtess show signs
of extreme distress.

  "Functions  should be  written  in such  a  way as  to minimise  the
astonishement of the user" ...

  /Joe




More information about the erlang-questions mailing list