"Stefan Keppler" <langgangel@...> writes:
> CL-USER> (defmethod make-instance ((class (eql 'the-answer)) &rest
> init-args)
> (declare (ignorable init-args))
> 42)
> #<STANDARD-METHOD MAKE-INSTANCE ((EQL THE-ANSWER)) {1003EE5211}>
>
> Is this a bug, or am I doing something stupid?
I think your method on make-instance is invalid for several reasons.
Firstly, well, it doesn't make an instance of the class requested (which
is the contract of make-instance...); if that's not convincing, the
method is also applicable to direct instances of standardized classes
(symbol, in this case), in contravention of the requirements in CLHS
11.1.2.1.2 (point 19).
What's happening is that the compiler optimizations on MAKE-INSTANCE
have taken advantage of these contracts and requirements by user
programs to optimize (make-instance 'the-answer) into fast code (or
rather to create space for regions of effectively JIT-compiled
initialization code). It does this secure in the knowledge that users
aren't really allowed to do what you've tried to do...
Best,
Christophe
|