Skip to content

Instantly share code, notes, and snippets.

@g000001
Created December 24, 2013 20:19
Show Gist options
  • Save g000001/8117461 to your computer and use it in GitHub Desktop.
Save g000001/8117461 to your computer and use it in GitHub Desktop.
(let* ((class (find-class 'ztesch))
(class1 (fare-mop:remake-object
class
:direct-slots
`((:name bar
:readers (bar)
:writers nil
:initargs (:bar)
:initfunction ,(constantly nil)
:initform nil)
,@(mapcar
(lambda (x)
`(:name
,(c2mop:slot-definition-name x)
:writers
,(c2mop:slot-definition-writers x)
:initargs
,(c2mop:slot-definition-initargs x)
:initfunction
,(c2mop:slot-definition-initfunction x)
:initform
,(c2mop:slot-definition-initform x)))
(c2mop:class-direct-slots class))))))
(write-line "-----------------------------")
(describe (make-instance class1 :bar 42))
(write-line "-----------------------------")
(describe (change-class (make-instance class1 :bar 42) class)))
;>> -----------------------------
;>> #<ZTESCH {10151E9473}>
;>> [standard-object]
;>>
;>> Slots with :INSTANCE allocation:
;>> BAR = 42
;>> FOO = NIL
;>> -----------------------------
;>> #<#<STANDARD-CLASS ZTESCH> {10151EC443}>
;>> [standard-object]
;>>
;>> Slots with :INSTANCE allocation:
;>> FOO = NIL
;>>
;=> <no values>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment