[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
early error detection
Date: Fri, 17 Feb 89 08:59 CST
From: firstname.lastname@example.org (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.
You're right - I said that rather hastily based on a quick reading of
the documentation, and realized only afterward that I had misinterpreted
it. My only excuse is that I favor flavors and rarely use defstruct -
sorry I tried to say more than I know. But the point was that the
complaint had no basis given that the documentation states clearly
that the :type option is for controlling the implementation of the
data structure rather than for type checking.
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?