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

Sad historical sidelights: Return values -- NIL vs undefined



    Date: Mon, 2 Jan 1984  12:02 EST
    From: Scott E. Fahlman <Fahlman at CMU-CS-C.ARPA>

    ... If Guy really intends this phrase to be taken seriously, which implies
    special-casing every stream operation to handle this case, then some more
    motivation and discussion is needed.  In the absence of such, we are
    treating this as an error...

Looking at people's code over the years, I've noticed (as I'm sure others
have) it's generally much better to leave undefined values explicitly
undefined rather than to say NIL is returned. Not only does it cause the
compiler to do extra work and produce shoddier code, but I have actually
seen people write things like:
	(AND (PRED1 X)
	     (NOT (TERPRI))
	     (PRINC FOO)
	     (PRED2 X))
I've seen real Maclisp code that did this sort of silliness. Whenever you
needlessly define return values for things, you just set yourself up for
bitching from people who've taught themselves to depend on things they
should never have even considered using in the first place.

In general, I would say the return value of no function, operation, or 
whatever should be defined unless we are prepared to be happy with people 
picking up and using that value shamelessly.