chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: void as a return value (Re: [Chicken-users] DBI)


From: Ozzi
Subject: Re: void as a return value (Re: [Chicken-users] DBI)
Date: Wed, 27 Feb 2008 17:27:04 -0600
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)


Vincent Manis wrote:
\begin{rant}
On the subject of using void as a return value (rather than to indicate that
a function or method doesn't return anything), EWWWW.

Please, please, don't ever write functions that return void as anything other
than an indication that no value was returned.

#;44> (car (db-fetch-row (db-query "select salary where empname='Bilbo Baggins'")))
#;45>

I don't yet have an opinion on using void, but this function would return either

a list: ( (void) )
or an alist: ( (salary . (void) )

depending on which we used to represent rows. Either way, there would indeed be a return value.

So now, (a) you get no output, which might be mystifying and (b) car is now returning void. Neither of these violates any language rule, but each violates the Law of
Least Astonishment.

For SQL nulls, one could use '(), as has been mentioned; alternatively, an object called the-SQL-null-object could be created (perhaps as a record type value).

Incidentally, there are several different meanings for null in SQL, including no information, not applicable, no value presently exists (but one might in the future), etc. You can find lengthy essays on the appropriateness of using NULL in several of Chris Date's `Writings on Database' books. People have enough trouble understanding SQL null without further conflating it with `this function returns no values'.

\end{rant}

Sorry :-) -- vincent


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users




reply via email to

[Prev in Thread] Current Thread [Next in Thread]