The Power of Dynamic Multi-Methods (Work-In-Progress Paper)

Total Page:16

File Type:pdf, Size:1020Kb

The Power of Dynamic Multi-Methods (Work-In-Progress Paper) Mµl: The Power of Dynamic Multi-Methods (Work-In-Progress Paper) Isaac Oscar Gariano Marco Servetto Victoria University of Wellington Victoria University of Wellington Wellington, New Zealand Wellington, New Zealand [email protected] [email protected] Abstract 1 Introduction Multi-methods are a straightforward extension of traditional Most object oriented (and functional1) languages support (single) dynamic dispatch, which is the core of most object only single dynamic dispatch: the code executed by a method oriented languages. With multi-methods, a method call will call is determined by a single argument (the receiver). For select an appropriate implementation based on the values of example, to evaluate a call like x.add(y), the value of x will multiple arguments, and not just the first/receiver. Language be inspected for a definition of an add method (depending support for both single and multiple dispatch is typically on the language, this may be found in a slot/field1 [ ], class designed to be used in conjunction with other object oriented [8], and/or parent object of x [16]) . This approach can be in- features, in particular classes and inheritance. But are these flexible for two main reasons: the value of y is ignored when extra features really necessary? selecting the implementation of add and only the creator of Mµl is a dynamic language designed to be as simple as x can define an add method. possible but still supporting flexible abstraction and poly- Multi-methods [2, 4, 6, 10, 11, 13–15, 17] are one approach morphism. Mµl provides only two forms of abstraction: (ob- to overcoming these limitations: methods can be declared to ject) identities and (multi) methods. In Mµl method calls are dispatch based on the values of multiple arguments. Unlike dispatched based on the identity of arguments, as well as conventional single dispatch, multi-methods can usually be what other methods are defined on them. In order to keep declared outside of the objects/classes of any of their argu- Mµls design simple, when multiple method definitions are ments. Consider for example the following Julia code: applicable, the most recently defined one is chosen, not the add(x:: Number,y:: Number)=x+y most specific (as is conventional with dynamic dispatch). add(x:: Array,y:: Array)= In this paper we show how by defining methods at run- [add(xy[1], xy[2]) for xy= zip(x,y)] time, we obtain much of the power of classes and meta object add(x:: Array,y:: Number)=[add(xe,y) for xe=x] protocols, in particular the ability to dynamically modify the add(x:: Number,y:: Array)=[add(x, ye) for ye=y] state and behaviour of ‘classes’ of objects. add([[1,2],3],4)// evaluates to[[5,6],7] CCS Concepts • Software and its engineering → Ob- Thus a call like add(x;y) will first get the types of x and y, ject oriented languages; Procedures, functions and sub- say T1 and T2, and then execute the body of the add method :: :: :: 0 :: 0 routines; • Theory of computation → Object oriented con- defined with (_ T1,_ T2) (or (_ T1 ;:::; _ T2 ), 0 0 structs; for some super types T1 and T2 of T1 and T2, respectively). In the above example, Array and Number are core language Keywords object oriented languages, multi-methods, dy- types, yet we were allowed to define the various add methods; arXiv:1910.00709v1 [cs.PL] 1 Oct 2019 namic dispatch, meta-object-protocols this is in contrast to conventional single dispatch languages, in which users cannot easily write methods that dynamically ACM Reference Format: dispatch over pre-defined types/classes. Isaac Oscar Gariano and Marco Servetto. 2019. Mµl: The Power of Mµl is a language built around multi-methods as an at- Dynamic Multi-Methods: (Work-In-Progress Paper). Presented at tempt at being even more flexible by eliminating as many Workshop on Meta-Programming Techniques and Reflection (META’19). extra concepts as possible, whilst increasing the flexibility 6 pages. of multi-methods. This work is licensed under Creative Commons Attribution 4.0 International License (CC BY 4.0). META’19, October 20, 2019, Athens, Greece 1 © 2019 Copyright held by the owner/author(s). Since a function or lambda can be thought of as an object with a single ‘apply’ or ‘call’ method. 1 META’19, October 20, 2019, Athens, Greece Isaac Oscar Gariano and Marco Servetto 1.1 The Mµl Programming Language Finally, Mµl supports standard sequence expressions of the 0 0 The language of Mµl2 is designed to be as simple as possible, form e; e , and let expressions of the form x := e; e . We it is an expression based left-to-right call-by-value language present a formalised set of reduction-rules in AppendixA. with the following grammar (where x and µ are identifiers The following example demonstrates the aforementioned and ι is an ‘identity’): features in action: def foo(n){n}; j new j def j ( ) (Expression) e F t M µ e // create three distinct identies 0 0 e; e j x := e; e bar := new; baz := new; qux := new; foo(bar); foo(baz); foo(qux);// evaluates to bar, baz, and qux (Term) t F x j ι (Method) M F µ(p|c){ e} def foo(=bar){ baz}; foo(bar);// Now this evaluates to baz j = (Paramater) p F t t foo(qux);// Still evaluates to qux, as qux , bar (Constraint) c F µ(t) foo(qux);// Evaluates to qux A (ground) term (t) is either a standard variable name (x) or def foo(x| foo2(x)){ foo2(x)}; an identity (ι); during reduction, an x may be replaced by foo(bar);// Still evaluates to baz, as foo2(bar) is undefined an ι. Identities are the only kind of value in Mµl, their only def foo2(=bar){ bar}; intrinsic meaning is whether they are the same or different foo(bar);// now returns foo2(bar), which returns bar (i.e., their ‘identity’). An ι cannot appear in the source code, and can only be created by a new expression, which will Later on we will introduce syntax sugar for natural num- evaluate to a fresh identity that is distinct from any pre- bers, lists, and lambdas. Our examples also use string literals existing ones.; thus identities cannot be forged. of the form "text" which evaluate to an identity ι such that Methods (M) are global and are dynamically installed by an print(ι) will print text. 4 expression of the form def µ(p|c){ e}, or simply def µ(p){ e} We have implemented Mµl , with all the aforementioned when the c is empty. Here µ is the name of the method being features, in Racket [5] by using the ‘brag’ [18] parser gener- defined, however multiple methods may be defined with ator and an encoding of our reduction rules in PLT Redex the same name; the p and c are (comma separated) lists of [9]. We have used this to test that all the code examples parameters and constraints (respectively); and the body of presented in this paper behave as indicated. the method is given by e. The e, p, and c are interpreted in the scope where the def was evaluated, augmented with 2 Abstraction Support appropriate bindings for any pi of form x: i.e. methods are We now show how Mµl is powerful enough to encode various closures, as with traditional lambda expressions. A def ex- language features including mutable fields, ‘value equality’ pression does not reduce to a value/identity, and so cannot (as opposed to reference equality), multiple dynamic dispatch, be used as an argument to a method call or the RHS of a ‘:=’, and multiple inheritance. Similarly to meta-object-protocols, however it can be used as the body of another method3. Mµl allows such features to be used at runtime, allowing state A method call expression is of the form µ(e) and will and behaviour to by dynamically added to whole groups of first evaluate its arguments to identities ι and then reduce to object a time, thus providing support for meta-programming. 0 0 e p B ι , where µ(p|c){ e } is the most recently installed None of this power requires any extensions to Mµl, the two applicable method, and for each pi of form x, p B ι per- core abstractions of identities and methods are sufficient; forms standard capture-avoiding substitution of ι for x.A this is in contrast to most languages were such power is method µ(p|c){ e 0} is applicable to the call µ(ι) whenever provided by specific abstractions and syntactic forms. each p p B ι accepts the corresponding ι, and eachc p B ι is satisfied. When no such applicable method exists, reduc- 2.1 (Mutable) State tion will get stuck. Suppose we want to represent records: collections of named A parameter (p) of form t will accept any value, whereas (mutable) values, we can do this by representing the fields one of form =t will only accept the current value of t.A as methods (which are closures): constraint (c) is of form µ(t) and is satisfied whenever it has def new-point(x,y){//a 'constructor' fora 'record' a matching applicable method: i.e. whenever the call µ(t) is res := new; defined. def get-x(=res){x};//a 'getter' def get-y(=res){y}; // res is likea{x=x,y=y} record 2‘Mµl’ is pronounced like ‘mull’; the μ stands for the ancient Greek word res}; μέθοδος (‘methodos’), meaning pursuit of knowledge.
Recommended publications
  • Homework 2: Reflection and Multiple Dispatch in Smalltalk
    Com S 541 — Programming Languages 1 October 2, 2002 Homework 2: Reflection and Multiple Dispatch in Smalltalk Due: Problems 1 and 2, September 24, 2002; problems 3 and 4, October 8, 2002. This homework can either be done individually or in teams. Its purpose is to familiarize you with Smalltalk’s reflection facilities and to help learn about other issues in OO language design. Don’t hesitate to contact the staff if you are not clear about what to do. In this homework, you will adapt the “multiple dispatch as dispatch on tuples” approach, origi- nated by Leavens and Millstein [1], to Smalltalk. To do this you will have to read their paper and then do the following. 1. (30 points) In a new category, Tuple-Smalltalk, add a class Tuple, which has indexed instance variables. Design this type to provide the necessary methods for working with dispatch on tuples, for example, we’d like to have access to the tuple of classes of the objects in a given tuple. Some of these methods will depend on what’s below. Also design methods so that tuples can be used as a data structure (e.g., to pass multiple arguments and return multiple results). 2. (50 points) In the category, Tuple-Smalltalk, design other classes to hold the behavior that will be declared for tuples. For example, you might want something analogous to a method dictionary and other things found in the class Behavior or ClassDescription. It’s worth studying those classes to see what can be adapted to our purposes.
    [Show full text]
  • TAMING the MERGE OPERATOR a Type-Directed Operational Semantics Approach
    Technical Report, Department of Computer Science, the University of Hong Kong, Jan 2021. 1 TAMING THE MERGE OPERATOR A Type-directed Operational Semantics Approach XUEJING HUANG JINXU ZHAO BRUNO C. D. S. OLIVEIRA The University of Hong Kong (e-mail: fxjhuang, jxzhao, [email protected]) Abstract Calculi with disjoint intersection types support a symmetric merge operator with subtyping. The merge operator generalizes record concatenation to any type, enabling expressive forms of object composition, and simple solutions to hard modularity problems. Unfortunately, recent calculi with disjoint intersection types and the merge operator lack a (direct) operational semantics with expected properties such as determinism and subject reduction, and only account for terminating programs. This paper proposes a type-directed operational semantics (TDOS) for calculi with intersection types and a merge operator. We study two variants of calculi in the literature. The first calculus, called li, is a variant of a calculus presented by Oliveira et al. (2016) and closely related to another calculus by Dunfield (2014). Although Dunfield proposes a direct small-step semantics for her calcu- lus, her semantics lacks both determinism and subject reduction. Using our TDOS we obtain a direct + semantics for li that has both properties. The second calculus, called li , employs the well-known + subtyping relation of Barendregt, Coppo and Dezani-Ciancaglini (BCD). Therefore, li extends the more basic subtyping relation of li, and also adds support for record types and nested composition (which enables recursive composition of merged components). To fully obtain determinism, both li + and li employ a disjointness restriction proposed in the original li calculus.
    [Show full text]
  • Julia: a Fresh Approach to Numerical Computing
    RSDG @ UCL Julia: A Fresh Approach to Numerical Computing Mosè Giordano @giordano [email protected] Knowledge Quarter Codes Tech Social October 16, 2019 Julia’s Facts v1.0.0 released in 2018 at UCL • Development started in 2009 at MIT, first • public release in 2012 Julia co-creators won the 2019 James H. • Wilkinson Prize for Numerical Software Julia adoption is growing rapidly in • numerical optimisation, differential equations, machine learning, differentiable programming It is used and taught in several universities • (https://julialang.org/teaching/) Mosè Giordano (RSDG @ UCL) Julia: A Fresh Approach to Numerical Computing October 16, 2019 2 / 29 Julia on Nature Nature 572, 141-142 (2019). doi: 10.1038/d41586-019-02310-3 Mosè Giordano (RSDG @ UCL) Julia: A Fresh Approach to Numerical Computing October 16, 2019 3 / 29 Solving the Two-Language Problem: Julia Multiple dispatch • Dynamic type system • Good performance, approaching that of statically-compiled languages • JIT-compiled scripts • User-defined types are as fast and compact as built-ins • Lisp-like macros and other metaprogramming facilities • No need to vectorise: for loops are fast • Garbage collection: no manual memory management • Interactive shell (REPL) for exploratory work • Call C and Fortran functions directly: no wrappers or special APIs • Call Python functions: use the PyCall package • Designed for parallelism and distributed computation • Mosè Giordano (RSDG @ UCL) Julia: A Fresh Approach to Numerical Computing October 16, 2019 4 / 29 Multiple Dispatch using DifferentialEquations
    [Show full text]
  • Predicate Dispatching
    This pap er app ears in ECOOP the th Europ ean Conference on Ob ject Oriented Programming Brussels Belgium July pp Predicate Dispatching A Unied Theory of Dispatch Michael Ernst Craig Kaplan and Craig Chambers Department of Computer Science and Engineering University of Washington Seattle WA USA fmernstcskchambersgcswashingtonedu httpwwwcswashingtoneduresearchprojectscecil Abstract Predicate dispatching generalizes previous metho d dispatch mechanisms by p ermitting arbitrary predicates to control metho d ap plicabili ty and by using logical implication b etween predicates as the overriding relationship The metho d selected to handle a message send can dep end not just on the classes of the arguments as in ordinary ob jectoriented dispatch but also on the classes of sub comp onents on an arguments state and on relationships b etween ob jects This simple mechanism subsumes and extends ob jectoriented single and multiple dispatch MLstyle pattern matching predicate classes and classiers which can all b e regarded as syntactic sugar for predicate dispatching This pap er introduces predicate dispatching gives motivating examples and presents its static and dynamic semantics An implementation of predicate dispatching is available Introduction Many programming languages supp ort some mechanism for dividing the b o dy of a pro cedure into a set of cases with a declarative mechanism for selecting the right case for each dynamic invocation of the pro cedure Case selection can b e broken down into tests for applicability a case is a candidate
    [Show full text]
  • Concepts in Programming Languages Practicalities
    Concepts in Programming Languages Practicalities I Course web page: Alan Mycroft1 www.cl.cam.ac.uk/teaching/1617/ConceptsPL/ with lecture slides, exercise sheet and reading material. These slides play two roles – both “lecture notes" and “presentation material”; not every slide will be lectured in Computer Laboratory detail. University of Cambridge I There are various code examples (particularly for 2016–2017 (Easter Term) JavaScript and Java applets) on the ‘materials’ tab of the course web page. I One exam question. www.cl.cam.ac.uk/teaching/1617/ConceptsPL/ I The syllabus and course has changed somewhat from that of 2015/16. I would be grateful for comments on any remaining ‘rough edges’, and for views on material which is either over- or under-represented. 1Acknowledgement: various slides are based on Marcelo Fiore’s 2013/14 course. Alan Mycroft Concepts in Programming Languages 1 / 237 Alan Mycroft Concepts in Programming Languages 2 / 237 Main books Context: so many programming languages I J. C. Mitchell. Concepts in programming languages. Cambridge University Press, 2003. Peter J. Landin: “The Next 700 Programming Languages”, I T.W. Pratt and M. V.Zelkowitz. Programming Languages: CACM (published in 1966!). Design and implementation (3RD EDITION). Some programming-language ‘family trees’ (too big for slide): Prentice Hall, 1999. http://www.oreilly.com/go/languageposter http://www.levenez.com/lang/ ? M. L. Scott. Programming language pragmatics http://rigaux.org/language-study/diagram.html (4TH EDITION). http://www.rackspace.com/blog/ Elsevier, 2016. infographic-evolution-of-computer-languages/ I R. Harper. Practical Foundations for Programming Plan of this course: pick out interesting programming-language Languages.
    [Show full text]
  • Characteristics of Mathematical Modeling Languages That
    www.nature.com/npjsba ARTICLE OPEN Characteristics of mathematical modeling languages that facilitate model reuse in systems biology: a software engineering perspective ✉ Christopher Schölzel 1 , Valeria Blesius1, Gernot Ernst2,3 and Andreas Dominik 1 Reuse of mathematical models becomes increasingly important in systems biology as research moves toward large, multi-scale models composed of heterogeneous subcomponents. Currently, many models are not easily reusable due to inflexible or confusing code, inappropriate languages, or insufficient documentation. Best practice suggestions rarely cover such low-level design aspects. This gap could be filled by software engineering, which addresses those same issues for software reuse. We show that languages can facilitate reusability by being modular, human-readable, hybrid (i.e., supporting multiple formalisms), open, declarative, and by supporting the graphical representation of models. Modelers should not only use such a language, but be aware of the features that make it desirable and know how to apply them effectively. For this reason, we compare existing suitable languages in detail and demonstrate their benefits for a modular model of the human cardiac conduction system written in Modelica. npj Systems Biology and Applications (2021) 7:27 ; https://doi.org/10.1038/s41540-021-00182-w 1234567890():,; INTRODUCTION descriptions of experiment setup or design choices6–8. A recent As the understanding of biological systems grows, it becomes study by curators of the BioModels database showed that only 8 more and more apparent that their behavior cannot be reliably 51% of 455 published models were directly reproducible .Inan 9 predicted without the help of mathematical models. In the past, extreme case, Topalidou et al.
    [Show full text]
  • Strategic Location and Dispatch Management of Assets in a Military Medical Evacuation Enterprise Phillip R
    Air Force Institute of Technology AFIT Scholar Theses and Dissertations Student Graduate Works 6-19-2019 Strategic Location and Dispatch Management of Assets in a Military Medical Evacuation Enterprise Phillip R. Jenkins Follow this and additional works at: https://scholar.afit.edu/etd Part of the Operations and Supply Chain Management Commons Recommended Citation Jenkins, Phillip R., "Strategic Location and Dispatch Management of Assets in a Military Medical Evacuation Enterprise" (2019). Theses and Dissertations. 2292. https://scholar.afit.edu/etd/2292 This Dissertation is brought to you for free and open access by the Student Graduate Works at AFIT Scholar. It has been accepted for inclusion in Theses and Dissertations by an authorized administrator of AFIT Scholar. For more information, please contact [email protected]. Strategic Location and Dispatch Management of Assets in a Military Medical Evacuation Enterprise DISSERTATION Phillip R. Jenkins, Capt, USAF AFIT-ENS-DS-19-J-037 DEPARTMENT OF THE AIR FORCE AIR UNIVERSITY AIR FORCE INSTITUTE OF TECHNOLOGY Wright-Patterson Air Force Base, Ohio DISTRIBUTION STATEMENT A APPROVED FOR PUBLIC RELEASE; DISTRIBUTION UNLIMITED. The views expressed in this document are those of the author and do not reflect the official policy or position of the United States Air Force, the United States Department of Defense or the United States Government. This material is declared a work of the U.S. Government and is not subject to copyright protection in the United States. AFIT-ENS-DS-19-J-037 STRATEGIC LOCATION AND DISPATCH MANAGEMENT OF ASSETS IN A MILITARY MEDICAL EVACUATION ENTERPRISE DISSERTATION Presented to the Faculty Graduate School of Engineering and Management Air Force Institute of Technology Air University Air Education and Training Command in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy Phillip R.
    [Show full text]
  • First-Class Dynamic Types (2019)
    First-Class Dynamic Types∗ Michael Homer Timothy Jones James Noble School of Engineering Montoux School of Engineering and Computer Science New York, USA and Computer Science Victoria University of Wellington [email protected] Victoria University of Wellington New Zealand New Zealand [email protected] [email protected] Abstract 1 Introduction Since LISP, dynamic languages have supported dynamically- Most dynamically-typed languages do not provide much sup- checked type annotations. Even in dynamic languages, these port for programmers incorporating type checks in their annotations are typically static: tests are restricted to check- programs. Object-oriented languages have dynamic dispatch ing low-level features of objects and values, such as primi- and often explicit “instance of” reflective operations, grad- tive types or membership of an explicit programmer-defined ual typing provides mixed-mode enforcement of a single class. static type system, and functional languages often include We propose much more dynamic types for dynamic lan- pattern-matching partial functions, all of which are relatively guages — first-class objects that programmers can custom- limited at one end of the spectrum. At the other end, lan- ise, that can be composed with other types and depend on guages like Racket support higher-order dynamic contract computed values — and to use these first-class type-like val- systems, wrapping objects to verify contracts lazily, and with ues as types. In this way programs can define their own con- concomitant power, complexity, and overheads [10, 51]. ceptual models of types, extending both the kinds of tests Programmers may wish for a greater level of run-time programs can make via types, and the guarantees those tests checking than provided by the language, or merely different can provide.
    [Show full text]
  • (Dynamic (Programming Paradigms)) Performance and Expressivity Didier Verna
    (Dynamic (programming paradigms)) Performance and expressivity Didier Verna To cite this version: Didier Verna. (Dynamic (programming paradigms)) Performance and expressivity. Software Engineer- ing [cs.SE]. LRDE - Laboratoire de Recherche et de Développement de l’EPITA, 2020. hal-02988180 HAL Id: hal-02988180 https://hal.archives-ouvertes.fr/hal-02988180 Submitted on 4 Nov 2020 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. THÈSE D’HABILITATION À DIRIGER LES RECHERCHES Sorbonne Université Spécialité Sciences de l’Ingénieur (DYNAMIC (PROGRAMMING PARADIGMS)) PERFORMANCE AND EXPRESSIVITY Didier Verna [email protected] Laboratoire de Recherche et Développement de l’EPITA (LRDE) 14-16 rue Voltaire 94276 Le Kremlin-Bicêtre CEDEX Soutenue le 10 Juillet 2020 Rapporteurs: Robert Strandh Université de Bordeaux, France Nicolas Neuß FAU, Erlangen-Nürnberg, Allemagne Manuel Serrano INRIA, Sophia Antipolis, France Examinateurs: Marco Antoniotti Université de Milan-Bicocca, Italie Ralf Möller Université de Lübeck, Allemagne Gérard Assayag IRCAM, Paris, France DOI 10.5281/zenodo.4244393 Résumé (French Abstract) Ce rapport d’habilitation traite de travaux de recherche fondamentale et appliquée en informatique, effectués depuis 2006 au Laboratoire de Recherche et Développement de l’EPITA (LRDE). Ces travaux se situent dans le domaine des langages de pro- grammation dynamiques, et plus particulièrement autour de leur expressivité et de leur performance.
    [Show full text]
  • Multiple Dispatch As Dispatch on Tuples Gary T
    Computer Science Technical Reports Computer Science 7-1998 Multiple Dispatch as Dispatch on Tuples Gary T. Leavens Iowa State University Todd Millstein Iowa State University Follow this and additional works at: http://lib.dr.iastate.edu/cs_techreports Part of the Systems Architecture Commons, and the Theory and Algorithms Commons Recommended Citation Leavens, Gary T. and Millstein, Todd, "Multiple Dispatch as Dispatch on Tuples" (1998). Computer Science Technical Reports. 131. http://lib.dr.iastate.edu/cs_techreports/131 This Article is brought to you for free and open access by the Computer Science at Iowa State University Digital Repository. It has been accepted for inclusion in Computer Science Technical Reports by an authorized administrator of Iowa State University Digital Repository. For more information, please contact [email protected]. Multiple Dispatch as Dispatch on Tuples Abstract Many popular object-oriented programming languages, such as C++, Smalltalk-80, Java, and Eiffel, do not support multiple dispatch. Yet without multiple dispatch, programmers find it difficult to express binary methods and design patterns such as the ``visitor'' pattern. We describe a new, simple, and orthogonal way to add multimethods to single-dispatch object-oriented languages, without affecting existing code. The new mechanism also clarifies many differences between single and multiple dispatch. Keywords Multimethods, generic functions, object-oriented programming languages, single dispatch, multiple dispatch, tuples, product types, encapsulation,
    [Show full text]
  • Array Operators Using Multiple Dispatch: a Design Methodology for Array Implementations in Dynamic Languages
    Array Operators Using Multiple Dispatch: A design methodology for array implementations in dynamic languages The MIT Faculty has made this article openly available. Please share how this access benefits you. Your story matters. Citation Jeff Bezanson, Jiahao Chen, Stefan Karpinski, Viral Shah, and Alan Edelman. 2014. Array Operators Using Multiple Dispatch: A design methodology for array implementations in dynamic languages. In Proceedings of ACM SIGPLAN International Workshop on Libraries, Languages, and Compilers for Array Programming (ARRAY '14). ACM, New York, NY, USA, 56-61, 6 pages. As Published http://dx.doi.org/10.1145/2627373.2627383 Publisher Association for Computing Machinery (ACM) Version Author's final manuscript Citable link http://hdl.handle.net/1721.1/92858 Terms of Use Creative Commons Attribution-Noncommercial-Share Alike Detailed Terms http://creativecommons.org/licenses/by-nc-sa/4.0/ Array Operators Using Multiple Dispatch Array Operators Using Multiple Dispatch A design methodology for array implementations in dynamic languages Jeff Bezanson Jiahao Chen Stefan Karpinski Viral Shah Alan Edelman MIT Computer Science and Artificial Intelligence Laboratory [email protected], [email protected], [email protected], [email protected], [email protected] Abstract ficient, such as loop fusion for array traversals and common subex- Arrays are such a rich and fundamental data type that they tend to pression elimination for indexing operations [3, 24]. Many lan- be built into a language, either in the compiler or in a large low- guage implementations therefore choose to build array semantics level library. Defining this functionality at the user level instead into compilers. provides greater flexibility for application domains not envisioned Only a few of the languages that support n-arrays, however, by the language designer.
    [Show full text]
  • Function Programming in Python
    Functional Programming in Python David Mertz Additional Resources 4 Easy Ways to Learn More and Stay Current Programming Newsletter Get programming related news and content delivered weekly to your inbox. oreilly.com/programming/newsletter Free Webcast Series Learn about popular programming topics from experts live, online. webcasts.oreilly.com O’Reilly Radar Read more insight and analysis about emerging technologies. radar.oreilly.com Conferences Immerse yourself in learning at an upcoming O’Reilly conference. conferences.oreilly.com ©2015 O’Reilly Media, Inc. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. #15305 Functional Programming in Python David Mertz Functional Programming in Python by David Mertz Copyright © 2015 O’Reilly Media, Inc. All rights reserved. Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). See: http://creativecommons.org/licenses/by-sa/4.0/ Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Editor: Meghan Blanchette Interior Designer: David Futato Production Editor: Shiny Kalapurakkel Cover Designer: Karen Montgomery Proofreader: Charles Roumeliotis May 2015: First Edition Revision History for the First Edition 2015-05-27: First Release The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Functional Pro‐ gramming in Python, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc.
    [Show full text]