Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

EROSについて

1,988 views

Published on

github: https://github.com/stibear/eros

Published in: Technology
  • Login to see the comments

EROSについて

  1. 1. Picrinについて すてぃべあ (@stibear1996)
  2. 2. Picrin Features ● R7RS compatibility ● reentrant design (all VM states are stored in single global state object) ● bytecode interpreter (based on stack VM) ● direct threaded VM ● internal representation by nan-boxing ● conservative call/cc implementation (users can freely interleave native stack with VM stack)
  3. 3. Picrin Features (Cont.) ● exact GC (simple mark and sweep, partially reference count is used as well) ● string representation by rope data structure ● support full set hygienic macro transformers, including implicit renaming macros ● extended library syntax ● advanced REPL support (multi-line input, etc) ● tiny & portable library (all functions will be in libpicrin.so)
  4. 4. 皆さんご存知のことと思います
  5. 5. ので割愛します
  6. 6. Picrinの(上に乗せようと企んでいる) オブジェクトシステム について 改題して… すてぃべあ (@stibear1996)
  7. 7. Lispのオブジェクトシステム といえば
  8. 8. 勿論CLOS
  9. 9. ですが
  10. 10. 今回は
  11. 11. CLOSではなく
  12. 12. 新たなオブジェクトシステム
  13. 13. その名も…
  14. 14. EROS
  15. 15. イーロス EROS ※エロスではない
  16. 16. EROS ● Extensible Relational Object System ● 集合論ベース ● 必要に応じてinclusion関係を付与可能 – define-relation
  17. 17. EROS ● オブジェクトが 「自分がどのクラスか知っている」 ● ではなく ● クラスが 「どのオブジェクトが自分に属すか知っている」 ● という発想の転換 ● するとclass-ofは単なる1つのメソッドになる
  18. 18. 定義を見てみる
  19. 19. define-class (define-record-type class (make-class membership) class? (membership class-membership)) (define-syntax define-class (syntax-rules () ((_ class-name membership) (define class-name (make-class membership)))))
  20. 20. クラス定義 (define-class <value> (lambda (obj) #t)) (define-class <class> class?) (define-class <number> number?) (define-class <string> string?) (define-class <procedure> procedure?) (define-class <boolean> boolean?)
  21. 21. Instance-of (define (instance-of? obj class) ((class-membership class) obj))
  22. 22. define-generic (define-syntax define-generic (syntax-rules () ((_ generic-name) (define (generic-name . args) (let ((method-alst (dictionary-ref (attribute generic-name) method-sym))) (if method-alst (apply (find-method args method-alst) args) (error "No methods found")))))))
  23. 23. add-method (define (add-method generic-fn arg-type-list closure) (dictionary-set! (attribute generic-fn) 'methods `((,arg-type-list . ,closure) . ,(let ((x (dictionary-ref (attribute generic-fn) 'methods))) (if x x '())))))
  24. 24. define-method (define-syntax define-method (ir-macro-transformer (lambda (form rename compare) (let ((method-name (caadr form)) (args (cdadr form)) (body (cddr form))) `(add-method ,method-name (list ,@(method-args-types args)) (lambda ,(method-args-params args) ,@body))))))
  25. 25. find-method (define (find-method args method-lst) (let ((method (member args method-lst (lambda (x y) (every values (map instance-of? x (car y))))))) (if method (cdar method) (error "No methods found"))))
  26. 26. class-of (define-generic class-of) (define-method (class-of obj) <value>) (define-method (class-of (num <number>)) <number>) (define-method (class-of (str <string>)) <string>) (define-method (class-of (proc <procedure>)) <procedure>) (define-method (class-of (bool <boolean>)) <boolean>)
  27. 27. 実演
  28. 28. 課題 ● define-relationの実装 ● Picrinにマージされたい
  29. 29. 参考URL ● Gist https://gist.github.com/stibear/6f5bd035a6a725d8add6 ● Github https://github.com/stibear/eros
  30. 30. ご清聴ありがとうございました

×