Your SlideShare is downloading. ×
0
Property Based Dispatch                                                                 in Functional Languages     Proper...
Property Based Dispatch                            in Functional Languages   Introduction               Introduction      ...
Property Based Dispatch                                                       in Functional Languages Olena Properties    ...
Property Based Dispatch                                                               in Functional Languages Shift Algori...
Property Based Dispatch                                                                   in Functional Languages C++ Impl...
Property Based Dispatch                                                           in Functional Languages Shift Algorithm ...
Property Based Dispatch                                                                       in Functional Languages C++ ...
Property Based Dispatch                                                        in Functional Languages Lisp Implementation...
Property Based Dispatch                                                                 in Functional Languages Lisp Imple...
Property Based Dispatch                               in Functional Languages  Implementation Overview                    ...
Property Based Dispatch                                    in Functional Languages  Fibonacci                             ...
Property Based Dispatch                                    in Functional Languages  Fibonacci                             ...
Property Based Dispatch                                                                in Functional Languages  Fibonacci ...
Property Based Dispatch                                                                in Functional Languages  Fibonacci ...
Property Based Dispatch                                          in Functional Languages  Javascript Full Dispatch        ...
Property Based Dispatch                                            in Functional Languages  Python Decorators             ...
Property Based Dispatch                                           in Functional Languages  Haskell Pattern Matching       ...
Property Based Dispatch                                            in Functional Languages  MOP                           ...
Property Based Dispatch                                                                 in Functional Languages  Filtered ...
Property Based Dispatch                                             in Functional Languages  Multimethod.js               ...
Property Based Dispatch                          in Functional Languages  Conclusion                            Introducti...
Property Based Dispatch                   in Functional Languages  Questions ?                     Introduction           ...
Upcoming SlideShare
Loading in...5
×

Climb - Property-based dispatch in functional languages [Slides]

244

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
244
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Climb - Property-based dispatch in functional languages [Slides]"

  1. 1. Property Based Dispatch in Functional Languages Property Based Dispatch in Functional Introduction Olena Properties Languages Lisp Implementation Other Languages Conclusion Christopher Chedeau LRDE Laboratoire de Recherche et D´veloppement d’EPITA e January 18, 2012 http://lrde.epita.fr/1 / 19 Christopher Chedeau
  2. 2. Property Based Dispatch in Functional Languages Introduction Introduction Olena Properties Lisp Implementation Olena Properties Other Languages Conclusion Lisp Implementation Other Languages Conclusion2 / 19 Christopher Chedeau
  3. 3. Property Based Dispatch in Functional Languages Olena Properties Introduction Olena Properties Lisp Implementation Other Languages Conclusion Type Name Values image dimension any, one d, two d, three d3 / 19 Christopher Chedeau
  4. 4. Property Based Dispatch in Functional Languages Shift Algorithm Introduction Olena Properties Lisp Implementation Other Languages Conclusion definition any unique multiple varying Specialization (1) Specialization (2) size any fixed Specialization (1) Specialization (2)4 / 19 Christopher Chedeau
  5. 5. Property Based Dispatch in Functional Languages C++ Implementation shift(Window<W>& win, mln dpsite(W)& dp) { Introduction Olena Properties // Dispatch on definition property Lisp shift (mln trait window definition(W)(), exact(win), dp); Implementation } Other Languages Conclusion shift (trait::window::definition::unique, W& win, mln dpsite(W)& dp) { /* Specialized implementation (1) */ } shift (trait::window::definition::multiple, W& win, mln dpsite(W)& dp) { /* Specialized implementation (2) */ }5 / 19 Christopher Chedeau
  6. 6. Property Based Dispatch in Functional Languages Shift Algorithm Introduction Olena Properties definition Lisp Implementation any unique multiple varying Specialization (1) Ö Ö Ö Other Languages Ö Ö Ö Conclusion Specialization (2) size any fixed Specialization (1) Ö Specialization (2)6 / 19 Christopher Chedeau
  7. 7. Property Based Dispatch in Functional Languages C++ Implementation shift(Window<W>& win, mln dpsite(W)& dp) { Introduction Olena Properties mlc is not(mln trait window definition(W), Lisp trait::window::definition::any)::check(); Implementation mlc is not(mln trait window definition(W), Other Languages trait::window::definition::varying)::check(); Conclusion shift (mln trait window definition(W)(), exact(win), dp); } shift (trait::window::definition::unique, W& win, mln dpsite(W)& dp) { mlc is(mln trait window size(W), trait::window::size::fixed)::check(); }7 / 19 Christopher Chedeau
  8. 8. Property Based Dispatch in Functional Languages Lisp Implementation Introduction Olena Properties Lisp Implementation Other Languages (defmethod shift ( (defmethod shift ( Conclusion (win window) (win window) (dp dpsite)) (dp dpsite)) ; Specialization (1) ; Specialization (2) ) )8 / 19 Christopher Chedeau
  9. 9. Property Based Dispatch in Functional Languages Lisp Implementation Introduction Olena Properties Lisp (defalgo shift ( (defalgo shift ( Implementation (win (win Other Languages Conclusion :properties ( :properties ( :definition :unique :definition :multiple) :size :fixed) window) window) (dp dpsite)) (dp dpsite)) ; Specialization (2) ; Specialization (1) ) )9 / 19 Christopher Chedeau
  10. 10. Property Based Dispatch in Functional Languages Implementation Overview Introduction Olena Properties Lisp Implementation Other Languages Conclusion10 / 19 Christopher Chedeau
  11. 11. Property Based Dispatch in Functional Languages Fibonacci Introduction Olena Properties (defalgo fibo ((n Lisp (lambda (n) (< n 2)))) Implementation n) Other Languages Conclusion11 / 19 Christopher Chedeau
  12. 12. Property Based Dispatch in Functional Languages Fibonacci Introduction Olena Properties (defalgo fibo ((n Lisp (lambda (n) (< n 2)))) Implementation n) Other Languages Conclusion (defun <2 (n) (< n 2)) (defalgo fibo ((n #’<2)) n)11 / 19 Christopher Chedeau
  13. 13. Property Based Dispatch in Functional Languages Fibonacci Introduction Olena Properties (defalgo fibo ((n (defun is (a) Lisp (lambda (n) (< n 2)))) (lambda (b) Implementation n) (eq a b))) Other Languages Conclusion (defalgo fibo ((n (is 0))) (defun <2 (n) (< n 2)) 0) (defalgo fibo ((n #’<2)) (defalgo fibo ((n (is 1))) n) 1)11 / 19 Christopher Chedeau
  14. 14. Property Based Dispatch in Functional Languages Fibonacci Introduction Olena Properties (defalgo fibo ((n (defun is (a) Lisp (lambda (n) (< n 2)))) (lambda (b) Implementation n) (eq a b))) Other Languages Conclusion (defalgo fibo ((n (is 0))) (defun <2 (n) (< n 2)) 0) (defalgo fibo ((n #’<2)) (defalgo fibo ((n (is 1))) n) 1) (defalgo fibo (n) (+ (fibo (− n 2)) (fibo (− n 1))))11 / 19 Christopher Chedeau
  15. 15. Property Based Dispatch in Functional Languages Javascript Full Dispatch Introduction Olena Properties Lisp Implementation fibo = FullDispatch() Other Languages Conclusion fibo.add [(n) −> n < 2], (n) −> n fibo.add [null], (n) −> fibo(n − 1) + fibo(n − 2)12 / 19 Christopher Chedeau
  16. 16. Property Based Dispatch in Functional Languages Python Decorators Introduction Olena Properties Lisp Implementation @dispatch(inside(0, 1)) Other Languages def fibo(n): Conclusion return n @dispatch(int) def fibo(n): return fibo(n − 1) + fibo(n − 2)13 / 19 Christopher Chedeau
  17. 17. Property Based Dispatch in Functional Languages Haskell Pattern Matching Introduction Olena Properties Lisp Implementation Other Languages Conclusion fibo 0 = 0 fibo 1 = 1 fibo n = fibo (n − 1) + fibo (n − 2)14 / 19 Christopher Chedeau
  18. 18. Property Based Dispatch in Functional Languages MOP Introduction Olena Properties Lisp Implementation (defmethod fibo (n) Other Languages (+ (fibo (− n 1)) (fibo (− n 2)))) Conclusion (defmethod fibo ((n (eql 1))) n) (defmethod fibo ((n (eql 0))) n)15 / 19 Christopher Chedeau
  19. 19. Property Based Dispatch in Functional Languages Filtered Dispatch Introduction Olena Properties (defun state (n) Lisp Implementation (if (< n 2) Other Languages ’terminal Conclusion ’general)) (defmethod fibo :filter :state ((n (eql ’terminal))) n) (defmethod factorial :filter :state ((n (eql ’general))) (+ (fibo (− n 1)) (fibo (− n 2))))16 / 19 Christopher Chedeau
  20. 20. Property Based Dispatch in Functional Languages Multimethod.js Introduction Olena Properties Lisp fibo = multimethod() Implementation .dispatch((n) −> if n < 2 Other Languages ’terminal’ Conclusion else ’general’) .when(’terminal’, (n) −> n) .when(’general’, (n) −> fibo(n − 1) + fibo(n − 2))17 / 19 Christopher Chedeau
  21. 21. Property Based Dispatch in Functional Languages Conclusion Introduction Olena Properties Lisp Implementation Other Languages Conclusion Conclusion18 / 19 Christopher Chedeau
  22. 22. Property Based Dispatch in Functional Languages Questions ? Introduction Olena Properties Lisp Implementation Other Languages Conclusion19 / 19 Christopher Chedeau
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×