Your SlideShare is downloading. ×

Meta-objective Lisp @名古屋 Reject 会議

1,980

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,980
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Meta-objective Lisp @dico_leque 2011/02/26 NagoyaRejectKaigi
  • 2. n Common Lisp Object System Metaobject Protocoln Gauche Scheme interpreter
  • 3. Lispn CLOS -- Common Lisp Object Systemn n ISLISP Object System -- ILOSn Rubyn ANSI Common Lisp Lisp
  • 4. CLOS (1)n n (define-class <foo> () ((slot1) (slot2)))n n (define-class <baz> (<foo> <bar>) ())
  • 5. CLOS (2)n generic- functionn (define-generic foo) (define-method foo ((x <sequence>) (y <sequence>)) 0) (define-method foo ((x <sequence>) (y <string>)) 1) (define-method foo ((x <string>) (y <sequence>)) 2) (define-method foo ((x <string>) (y <string>)) 3) (foo () ()) ; => 0 (foo () "a") ; => 1 (foo "a" #()) ; => 2 (foo "a" "b") ; => 3
  • 6. CLOS (3)n CLOS CLOSnn
  • 7. MOPn Metaobject Protocol n introspection: API n intercessory: APIn intercessory
  • 8. Metaobjectsn n <class> <generic> <method>n (make <class>) (apply-generic-function <generic>)
  • 9. (1)nn <singleton-meta> maken (instance-of < >)n singleton singleton
  • 10. (1)(define-class <singleton-meta> (<class>) (%the-singleton-instance) )(define-method make ((class <singleton-meta>) . initargs) ...)(define-method instance-of ((class <singleton-meta>) . initargs) (apply make class initargs))(define-class <singleton-mixin> () () :metaclass <singleton-meta>) from gauche/lib/gauche/mop/singleton.scm
  • 11. (2) O/Rn DBn <orm> DB
  • 12. (2) O/R(define-class <orm> (<class>) ())(define-method compute-slots ((cl <orm>)) (let ((super-slots (next-method))) (lset-union (lambda (x y) (eq? (car x) (car y))) (map (lambda (name) `(,name :init-keyword ,(make-keyword name) :accessor ,(string->symbol (format "~A-of" name)))) (load-slot-names cl)) super-slots)))(define-class <foo> () () :metaclass <orm>) ※ load-slot-names
  • 13. (3)n Rubynn (eql 0) 0n <generic> (eql x)
  • 14. (3)(define-generic fact :class <eql-specializable-generic>)(define-method fact ((n (eql 0))) 1)(define-method fact ((n <integer>)) (* n (fact (- n 1))))
  • 15. (3)(define-class <eql-specializer> (<class>) ((object :getter eql-specializer-object :init-keyword :eql-specializer-object)))(define (eql obj) (make <eql-specializer> :eql-specializer-object obj))(define-class <eql-specializable-generic> (<generic>) ())(define-method compute-applicable-methods ((gf <eql-specializable-generic>) args) ...)(define-method sort-applicable-methods ((gf <eql-specializable-generic>) methods args) ...) ※ 60 http://d.hatena.ne.jp/leque/20110105/p1
  • 16. CLOS / MOPn n DB n n validator
  • 17. CLOS / MOPn n Pascal Costanza, Charlotte Herzeel, Jorge Vallejos, Theo D’Hondt: “Filtered dispatch”, Proceedings of the 2008 symposium on Dynamic languagesn n before, after, around n
  • 18. CLOS / MOPn n n lazy initializationn
  • 19. DSL MOPn DSL Domainn
  • 20. n Lisper DSLn CLOS MOP

×