ok or true?

Lennart Öhman lennart.ohman@REDACTED
Sun Feb 22 19:38:56 CET 2004


Hi, this is of course a matter of religion :-) But I have always
preached that one should look at what the opposite return value
will be if you have problem deciding.

So, if the opposite would be some kind of error ({error,Reason})
then 'ok' denotes a success.

One should also use the rule of not making assumptions about what
the return value will be used for. With this I mean that ok/error
makes such an assumption (about what is desired and what is not). But
true/false does not.

Good luck :-)

/Lennart

Shawn Pearce wrote:
> This has got to be an age old question:
> 
> 	Return 'ok' or 'true' on success?
> 
> I'm building a gen_serial module.  Looking at the gen_tcp API, the
> functions return 'ok' when they succeed.  Looking at the port BIF API,
> the BIFs all return 'true' when they succeed.
> 
> So which is it?  :-)
> 
> I've finally got async serial port IO working on Windows XP.  I need
> to get error handling in, and properly terminate the external port
> servers when the port is closed down, write some edoc, and then I'll
> release it to the list.  Should be sometime later this week.
> 
> I'd like to get the current serial contrib merged in with this driver
> too, so both Windows and UNIX can use the same Erlang code.
> 

-- 
-------------------------------------------------------------
Lennart Ohman                   phone   : +46-8-587 623 27
Sjoland & Thyselius Telecom AB  cellular: +46-70-552 6735
Sehlstedtsgatan 6               fax     : +46-8-667 8230
SE-115 28 STOCKHOLM, SWEDEN     email   : lennart.ohman@REDACTED




More information about the erlang-questions mailing list