(fix 'defclass) -> DEFKENNY



Linebreaks are your problem, as are nose demons. Your hard drive, however, should be safe:

(defmacro defkenny (class superclasses &rest class-spec)
`(defclass ,class ,superclasses
,@(let (definitargs class-options slots)
(loop with skip
for (spec next) on class-spec
if skip
do (setf skip nil)
else do (etypecase spec
(cons
(cond
((keywordp (car spec))
(assert (find (car spec) '(:documentation :metaclass)))
(push spec class-options))
((find (cadr spec) '(:initarg :type :initform :allocation :reader :writer :accessor :documentation))
(push (apply 'defkenny-canonicalize-slot spec) slots))
(t ;; must be shortform: (slotname initform &rest slotdef-key-values)
(push (apply 'defkenny-canonicalize-slot
(list* (car spec) :initform (cadr spec) (cddr spec))) slots))))
(keyword
(setf definitargs (append definitargs (list spec next)))
(setf skip t))
(symbol (push (list spec :initform nil
:initarg (intern (symbol-name spec) :keyword)
:accessor spec) slots)))
finally
(return (list* (nreverse slots)
(delete-if 'null
(list* `(:default-initargs ,@definitargs)
(nreverse class-options)))))))))

(defun defkenny-canonicalize-slot (slotname
&key
(type nil type-p)
(initform nil initform-p)
(initarg (intern (symbol-name slotname) :keyword))
(documentation nil documentation-p)
(unchanged-if nil unchanged-if-p)
(reader slotname reader-p)
(writer `(setf ,slotname) writer-p)
(accessor slotname accessor-p)
(allocation nil allocation-p))
(list* slotname :initarg initarg
(append
(when type-p (list :type type))
(when initform-p (list :initform initform))
(when unchanged-if-p (list :unchanged-if unchanged-if))
(when reader-p (list :reader reader))
(when writer-p (list :writer writer))
(when (or accessor-p
(not (and reader-p writer-p)))
(list :accessor accessor))
(when allocation-p (list :allocation allocation))
(when documentation-p (list :documentation documentation)))))

#+testkenny
(progn
(defclass md-test-super ()())

(defkenny defkenny-test (md-test-super)
(aaa :initform nil :initarg :aaa :accessor aaa)
(aa2 :documentation "hi mom")
bbb
(ccc 42 :allocation :class)
(ddd (c-in nil))
:superx 42 ;; default-initarg
(:documentation "as if!")))

=>
(defclass defkenny-test (md-test-super)
((aaa :initarg :aaa :initform nil :accessor aaa)
(aa2 :initarg :aa2 :accessor aa2 :documentation "hi mom")
(bbb :initform nil :initarg :bbb :accessor bbb)
(ccc :initarg :ccc :initform 42 :accessor ccc :allocation :class)
(ddd :initarg :ddd :initform (c-in nil) :accessor ddd))
(:default-initargs
:superx 42)
(:documentation "as if!"))

You are welcome.

kenny

--
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
.



Relevant Pages

  • Re: PHP Career Advice
    ... You may be able to build it in a weekend, but what about all the documentation for the NEXT guy who has to modify it, and the user documentation, and the training course and manual you have to write. ... The last $500k job I did..probably the last in my professional career - I spent about 4 days installing and setting up kit onsite, I spent 6 days configuring at base, I spent 2 weeks writing the spec, and another 5 days writing training courses and 14 days delivering them. ... Secondly you area systems analyst, and finally your are an ANAL PROG them coding to a spec, and after that the dreaded TECH AUTH and CODE TESTER who rip the thing to pieces and find all its problems and document the thing in PLAIN ENGLISH for the people who think computers are spawn of the devil.. ...
    (comp.lang.php)
  • Re: (fix defclass) -> DEFKENNY
    ... (defmacro defkenny (class superclasses &rest class-spec) ... for (spec next) on class-spec ... do (setf skip nil) ...
    (comp.lang.lisp)
  • Re: Ruby 1.9.0 is released
    ... Perhaps we could branch the 1.8 spec and 1.9 ... In message "Re: Ruby 1.9.0 is released" ... |Could you point out some areas that are in dire need of documentation? ... cooperate documentation writing. ...
    (comp.lang.ruby)
  • Re: DS10L Docs
    ... DS10L Quick Spec. ... DS10 Quick Setup ... workstation is almost non-existant online (and apparently it was never ... Well I have the complete documentation for the Miata and the XP1000 and I ...
    (comp.os.vms)
  • Re: How stupid is mktime() tm_mon
    ... less sexy wrote: ... Because that's what the documentation says it does. ... So much for reading the spec... ...
    (alt.comp.lang.learn.c-cpp)