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

New type specifier?

    Well, I freely admit that the big hole in my proposal is defining
what it means to "use" a VOID value.  I think that the best approach
is to be extremely facist.  The only places where a void expression
may be legal are:
  1] Any place where the value is immediately discarded: PROGN, etc.
  2] Any place in a function that can return multiple values.  In
     addition to tail-recursive positions, this includes the protected
     form of UNWIND-PROTECT and the values form for
     MULTIPLE-VALUE-PROG1 when these forms are in such a
     multiple-value position. 

Note that in either case, a void value may be illegal because the
result was declared to be of some other type:

(proclaim '(function frob-foo (foo) void))
(defun frob-foo (foo) ...)

(proclaim '(function make-foo ((member t nil)) foo))
(defun make-foo (frob-p)
  (let ((foo (cons-a-foo)))
    (if frob-p
	(frob-foo foo)

In this classic "oops, I forgot to return the value" example, the
compiler is quite justified in giving a warning, since one branch of
the IF can never be legally executed.  The function MAKE-FOO itself is
not erroneous, but the compiler could replace the call to FROB-FOO
with code that just signals an error.  When this happens, I would like
my compiler to tell me that something may be wrong, since there almost
certainly is.