2015-6-25 1 Distributed Meta- Programming (To appear GPCE’06) Rui Shi, Chiyan Chen and Hongwei Xi Boston University.

Slides:



Advertisements
Similar presentations
Chapter 2.2 – More about Ruby Maciej Mensfeld Presented by: Maciej Mensfeld More about Ruby dev.mensfeld.pl github.com/mensfeld senior.
Advertisements

1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Type Checking, Inference, & Elaboration CS153: Compilers Greg Morrisett.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
1 Mooly Sagiv and Greta Yorsh School of Computer Science Tel-Aviv University Modern Compiler Design.
Tim Sheard Oregon Graduate Institute Lecture 8: Operational Semantics of MetaML CSE 510 Section FSC Winter 2005 Winter 2005.
Recap 1.Programmer enters expression 2.ML checks if expression is “well-typed” Using a precise set of rules, ML tries to find a unique type for the expression.
March 4, 2005Susmit Sarkar 1 A Cost-Effective Foundational Certified Code System Susmit Sarkar Thesis Proposal.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Functional Programming. Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends.
Names and Bindings.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Distributed Meta- Programming Rui Shi, Chiyan Chen and Hongwei Xi Boston University.
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Tim Sheard Oregon Graduate Institute Lecture 4: Staging Interpreters CSE 510 Section FSC Winter 2004 Winter 2004.
Compiler Construction
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Ch.2: Syntax and Semantics Fall 2005.
1 Meta-Programming through Typeful Code Representation Chiyan Chen and Hongwei Xi Boston University.
Safety as a Software Metric Matthias Felleisen and Robert Corky Cartwright Rice University.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
01/17/20031 Guarded Recursive Datatype Constructors Hongwei Xi and Chiyan Chen and Gang Chen Boston University.
Functional programming: LISP Originally developed for symbolic computing Main motivation: include recursion (see McCarthy biographical excerpt on web site).
Cse321, Programming Languages and Compilers 1 6/19/2015 Lecture #18, March 14, 2007 Syntax directed translations, Meanings of programs, Rules for writing.
10 September Implementing Staged Computation Chiyan Chen and Hongwei Xi Boston University.
Type Specialisation John Hughes Chalmers University.
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
PADL041 A Typeful Approach to Object- Oriented Programming with Multiple Inheritance Chiyan Chen, Rui Shi, Hongwei Xi Computer Science Dept. Boston.
1 A Short Introduction to (Object-Oriented) Type Systems Kris De Volder.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
Chapter TwelveModern Programming Languages1 Memory Locations For Variables.
Staging in Haskell What is Staging What does it Mean Using Template Haskell.
 The design of the imperative languages is based directly on the von Neumann architecture  Efficiency is the primary concern  Low-level specifications:
Bindings and scope  Bindings and environments  Scope and block structure  Declarations Programming Languages 3 © 2012 David A Watt, University.
Agile and Efficient Domain-Specific Languages using Multi-stage Programming in Java Mint Edwin Westbrook, Mathias Ricken, and Walid Taha.
Computer Science and Engineering College of Engineering The Ohio State University Interfaces The credit for these slides goes to Professor Paul Sivilotti.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAM DESIGN WITH C++ Templates.
10/16/2015IT 3271 All about binding n Variables are bound (dynamically) to values n values must be stored somewhere in the memory. Memory Locations for.
Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
CSC 580 – Theory of Programming Languages, Spring, 2009 Week 9: Functional Languages ML and Haskell, Dr. Dale E. Parson.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
Chapter 9: Functional Programming in a Typed Language.
1 Alex Proctor and Brian Lee for CSCI 431 at UNCA, Fall 2002 ML (Meta Language) a brief introduction Alex Proctor and Brian Lee For CSCI 431 at the University.
Implementing a Dependently Typed λ -Calculus Ali Assaf Abbie Desrosiers Alexandre Tomberg.
12/9/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Semantic Analysis II Type Checking EECS 483 – Lecture 12 University of Michigan Wednesday, October 18, 2006.
Advanced Functional Programming Tim Sheard 1 Lecture 17 Advanced Functional Programming Tim Sheard Oregon Graduate Institute of Science & Technology Lecture:
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Operational Semantics of Scheme
Type Checking and Type Inference
Programming Languages and Compilers (CS 421)
Functional Programming
Names and Attributes Names are a key programming language feature
ML: a quasi-functional language with strong typing
Java Programming Language
6.001 SICP Compilation Context: special purpose vs. universal machines
Object Oriented Programming in Java
A Modality for Safe Resource Sharing and Code Reentrancy
Programming Languages and Compilers (CS 421)
The Metacircular Evaluator
The Metacircular Evaluator
6.001 SICP Variations on a Scheme
Recursive Procedures and Scopes
Presentation transcript:

Distributed Meta- Programming (To appear GPCE’06) Rui Shi, Chiyan Chen and Hongwei Xi Boston University

Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

Meta-Programming (define (run code) (eval code nil)) (define (power n x) (if (= n 0) 1 `(*,x,(power (- n 1) x)))) ;;; (power 2 ‘x) yields (* x (* x 1)) (define square (run `(lambda (x),(power 2 ‘x)))) ;;; (power 3 ‘y) yields (* y (* y (* y 1))) (define cube (run `(lambda (y),(power 3 ‘y))))

Distributed Meta-Programming Cod e Run-time code generation Distributed execution

Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

`(“abc” + 10) (ill-typed) `(( y.x) 10) (open code) Un-typed Code Representation No guarantee on the safety of generated code.  Code can be syntactically ill-formed or ill-typed, which leads to run-time errors when executed at remote sites.  Issues of locality and heterogeneity of resources Different sites may have different resources and thus likely to provide different services. f : (Int ! L `(f 100) L’

Typeful Code Representation (T.C.R) The type of an object program can be reflected in the type of code which represents the program  E.g. code of type h , T i represents an object program of type T under the type environment . The type of the code also reflects where it should be sent for execution.  E.g. code of type h L, , T i can be sent to location L for execution. The compiler can statically guarantee that only well-typed code can be constructed at run-time and sent to proper locations for execution.

Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

The Language dist - Syntax

The Language dist – Types (1) Given a location L, we use loc(L) as a singleton type for locations  The only value in loc(L) is L itself.  here always refers to the location where the program is executed (dynamic binding). Name type: for the type of values referring some value of type T at location L.  rget T returns a local value through a name, which is of type 8 L. (loc(L), ) T

The Language dist – Types (2) Message Type: msg(L,T) for the type of values that can be interpreted at location L to yield a value of type T.  n2m turns a name to a message, which is of type  Constant Messages: refer to the messages which can be interpreted at all locations. E.g. $plus is a constant message of type 8 L.8 T. ) msg(L,T) 8 L.msg(L, int ! int ! int)

First-Order Code Constructors For example, the term x. y. y (x) can be represented as: which can be of type (with static variables properly instantiated) Lam (Lam (App (One, Shi (One)))) 8 L. h L, , int ! (int ! int) ! int i

An Example in dist rexec is to execute code remotely, which is of the following type: 8 L.8 T. (loc(L), h L, , T i) ) f : (int ! L L `(f 100) rget int (L, rexec (L, App (Lift (n2m f), Lift 100) )) of type h L, , int i

Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Discussion and Conclusion

The Language + dist We extend dist to + dist with some language constructs adopted from meta-programming (supported in Scheme and MetaML):  `(e) for the code representation of e  ^(e) for splicing the code e into the enclosing context  %(¢) is a shorthand for ^(Lift(¢))

More on + dist We have a transformation scheme from + dist to dist to justify the type soundness of + dist. + dist is implemented as a part of ATS (Applied Type System) framework. Programmers use the concrete syntax (ML-like) to write distributed meta-programs. We have a process to elaborate programs (partial type inference) in the concrete syntax to the formal syntax of + dist

An Example in Concrete Syntax of + dist typedef CodeType (L: loc) = int) -> int> fun rZeroFind {L:loc} (L:loc(L)) (n: (int -> L) : int = let val zeroFindCode : CodeType (L) = `(lam f => (fix aux i => if f (i) = 0 then i else aux (i+1)) 0) in rget_int (rexec (L, `(^zeroFindCode %(n2m n)))) end

Outline MP vs. DMP Typeful Code Representation The Language dist The Language + dist Conclusion

Conclusion A simple and general approach to support typed mobile computing. Combines meta-programming with distributed programming in a coherent manner. In future, we are planning to study issues such as exception handling and distributed garbage collection in this context.

Thank You!