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

early error detection



    Date: Fri, 17 Feb 89 08:59 CST
    From: ai.gooch@mcc.com (William D. Gooch)

      If you want type-checking done early, you could use the :alterant
    option to defstruct to add type checks to your code.  

Could you explain this?  I don't think :ALTERANT does what you think it
does.  I don't know of any way to get defstruct accessors or setters to
check that a structure is of the appropriate type.

What you can do is replace your defstructs with flavors.  Flavors can do
everything that defstructs can do (you could pretty easily define a new
defstruct macro that expanded into an appropriate defflavor), plus they
perform automatic type checking of the structure argument.  By defining
appropriate methods on the SETF operations you can also get checking of
stores.  But this comes at a cost -- method invocation is slower than
open-coded structure accessors.  TANSTAAFL.

I think the only sensible answer to this issue is to realize that no
architecture currently does "full" error checking, but the Symbolics
system does much more runtime error checking than is feasible on any
conventional system.  It's not perfect, but what is?

                                                barmar