It s Turtles All the Way Up: Self-Extensible Programming Languages in PLT Scheme

Size: px
Start display at page:

Download "It s Turtles All the Way Up: Self-Extensible Programming Languages in PLT Scheme"

Transcription

1 It s Turtles All the Way Up: Self-Extensible Programming Languages in PLT Scheme Matthew Flatt University of Utah 1

2 Different levels of extension... Syntactic abstraction (define-syntax-rule (define-thing id [cmd response...]...)...) New language constructs (class object% (define/public method...)...) New languages (: factorial (Number -> int f(int n) { return n+1; }... but all the same kind of turtle 2

3 Examples Lisp-Style Macros Scheme Lisp PLT Scheme Scheme Macros and Lexical Scope PLT Scheme Macros References and Related Work 3

4 Preprocessors vs. Macros import java.io.* house =... game.maze mazec javac 4

5 Preprocessors vs. Macros import java.io.* house.* javac game.java house =... house.maze mazec javac 15

6 Preprocessors vs. Macros import java.io.* house.* javac game.java house =... house.maze mazec javac maze.java java 26

7 Preprocessors vs. Macros (require "io.ss") (define-syntax define-place...) (define-place house...) game.ss schemec 27

8 Preprocessors vs. Macros (require "io.ss" "maze.ss") (define-place house...) game.ss schemec (define-syntax define-place...) maze.ss schemec 38

9 Preprocessors vs. Macros (require "io.ss" "house.ss") game.ss schemec (require "maze.ss") (define-place house...) house.ss schemec (define-syntax define-place...) maze.ss schemec 49

10 Parsing Source (... (...)...) S-expression function args body AST 50

11 Parsing #lang path Source (... (...)...) S-expression function args body AST 51

12 Parsing #lang path (module name path...) Source (... (...)...) S-expression function args body AST 52

13 Parsing #lang path (module name path...) Source (... (...)...) S-expression function args body AST (require path) 53

14 Parsing #lang path (module name path...) Source (... (...)...) S-expression function args body AST #reader path (require path) 54

15 Parsing #lang scheme (define (hi) "Hello") (module m scheme (define (hi) "Hello")) define hi function () "Hello" #lang (module m doclang (require scribble/manual) (bold "Hi")) import scribble/doc scribble/manual export doc define doc apply bold ("Hi") import apply #lang honu 1+2; (module m honu ; ) honu-procs print apply + (1 2) 55

16 Parsing Source (... (...)...) S-expression function args body AST 56

17 Parsing Source (... (...)...) S-expression function args body AST Read layer provides absolute control (

18 Parsing Source (... (...)...) S-expression function args body AST Expand layer can delay inside until after outside (define-place start... ([north house-front] [south desert])) (define-place house-front... ([in room] [south start])) int is_odd(int x) {... is_even(x-1); } int is_even(int x) {... is_odd(x-1); } 58

19 Expand-time Expressions (define-syntax three (lambda (stx) #'3)) (+ 1 (three)) 59

20 Expand-time Expressions (define-syntax three (lambda (stx) #'3)) (+ 1 (three)) 60

21 Expand-time Expressions (define-syntax three (lambda (stx) #'3)) (+ 1 (three)) 61

22 Lisp/Scheme: PL/I Template Haskell: Expand-time Expressions (define-syntax three (lambda (stx) #'3)) (+ 1 (three)) %Three : procedure ANS( 3 ); %end 1 + Three three s = [ 3 ] $(three) 62

23 Expand-time Expressions (require (for-syntax "roman-numerals.ss")) (define-syntax three (lambda (stx) #`(+ 1 #,(roman->number "II")))) (+ 1 (three)) 63

24 Expand-time Expressions (require (for-syntax "roman-numerals.ss")) (define-syntax three (lambda (stx) #`(+ 1 #,(roman->number "II")))) (+ 1 (three)) 64

25 Expand-time Expressions Demo: Check Syntax ( require (for-syntax "roman-numerals.ss")) (define-syntax three (lambda (stx) #`(+ 1 #,(roman->number "II")))) (+ 1 (three)) 65

26 Examples Lisp-Style Macros Scheme Macros and Lexical Scope Source (... (...)...) S-expression function args body AST PLT Scheme Macros References and Related Work 66

27 Pattern-Based Macros (define-syntax swap ) define-syntax indicates a macro definition 67

28 Pattern-Based Macros (define-syntax swap (syntax-rules () )) syntax-rules means a pattern-matching macro () means no keywords in the patterns 68

29 Pattern-Based Macros (define-syntax swap (syntax-rules () [pattern template]... [pattern template])) Any number of patterns to match Produce result from template of first match 69

30 Pattern-Based Macros (define-syntax swap (syntax-rules () ((swap a b) ))) Just one pattern for this macro: (swap a b) Each identifier matches anything in use (swap x y) a is x b is y (swap 9 (+ 1 7)) a is 9 b is (+ 1 7) 70

31 Pattern-Based Macros (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) Bindings substituted into template to generate the result (swap x y) (let ([tmp y]) (set! y x) (set! x tmp)) (swap 9 (+ 1 7)) (let ([tmp (+ 1 7)]) (set! (+ 1 7) 9) (set! 9 tmp)) 71

32 Lexical Scope (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) What if we swap a variable named tmp? (let ([tmp 5] [other 6]) (swap tmp other))? (let ([tmp 5] [other 6]) (let ([tmp other]) (set! other tmp) (set! tmp tmp))) 72

33 Lexical Scope (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) What if we swap a variable named tmp? (let ([tmp 5] [other 6]) (swap tmp other))? (let ([tmp 5] [other 6]) (let ([tmp other]) (set! other tmp) (set! tmp tmp))) This expansion would violate lexical scope 73

34 Lexical Scope (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) What if we swap a variable named tmp? (let ([tmp 5] [other 6]) (swap tmp other)) (let ([tmp 5] [other 6]) (let ([tmp 1 other]) (set! other tmp) (set! tmp tmp 1 ))) Rename the introduced binding 74

35 Lexical Scope: Local Bindings Lexical scope means that local macros work, too: (define (f x) (define-syntax swap-with-arg (syntax-rules () ((swap-with-arg y) (swap x y)))) (let ((z 12) (x 10)) ; Swaps z with original x: (swap-with-arg z)) ) 75

36 Transformer Definitions In general, define-syntax binds a transformer procedure: (define-syntax swap (syntax-rules...)) (define-syntax swap (lambda (stx) use syntax-object primitives to match stx and generate result )) 76

37 Matching Syntax and Having It, Too The syntax-case and #' forms combine patterns and arbitrary computation (syntax-case stx-expr () (pattern result-expr)... (pattern result-expr)) #'template 77

38 Matching Syntax and Having It, Too (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) (define-syntax swap (lambda (stx) (syntax-case stx () ((swap 1 a b) #'(let ((tmp b)) (set! b a) (set! a tmp)))))) 78

39 Matching Syntax and Having It, Too Check for identifiers before expanding: (define-syntax swap (lambda (stx) (syntax-case stx () ((swap a b) (if (and (identifier? #'a) (identifier? #'b)) #'(let ((tmp b)) (set! b a) (set! a tmp)) (raise-syntax-error 'swap "needs identifiers" stx)))))) 79

40 How Lexical Scope Works (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) Seems obvious that tmp can be renamed... 80

41 How Lexical Scope Works (define-syntax swap (syntax-rules () ((swap a b) (let-one (tmp b) (set! b a) (set! a tmp)) ))) 81

42 Can rename tmp: How Lexical Scope Works (define-syntax swap (syntax-rules () ((swap a b) (let-one (tmp b) (set! b a) (set! a tmp)) ))) (define-syntax let-one (syntax-rules () ((let-one (x v) body) (let ((x v)) body)))) 82

43 Cannot rename tmp: How Lexical Scope Works (define-syntax swap (syntax-rules () ((swap a b) (let-one (tmp b) (set! b a) (set! a tmp)) ))) (define-syntax let-one (syntax-rules () ((let-one (x v) body) (list 'x v body)))) 83

44 Cannot rename tmp: How Lexical Scope Works (define-syntax swap (syntax-rules () ((swap a b) (let-one (tmp b) (set! b a) (set! a tmp)) ))) (define-syntax let-one (syntax-rules () ((let-one (x v) body) (list 'x v body)))) Track identifier introductions, then rename only as binding forms are discovered 84

45 How Lexical Scope Works (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) Tracking avoids capture by introduced variables (let ([tmp 5] [other 6]) (swap tmp other)) (let ([tmp 5] [other 6]) (let 1 ([tmp 1 other]) (set! 1 other tmp) (set! 1 tmp tmp 1 ))) 1 means introduced by expansion tmp 1 does not capture tmp 85

46 How Lexical Scope Works (define-syntax swap (syntax-rules () ((swap a b) (let ((tmp b)) (set! b a) (set! a tmp))))) Tracking also avoids capture of introduced variables (let ([set! 5] [let 6]) (swap set! let)) (let ([set! 5] [let 6]) (let 1 ([tmp 1 let]) (set! 1 let set!) (set! 1 set! tmp 1 ))) set! does not capture set! 1 let does not capture let 1 86

47 How Lexical Scope Works (More Precisely) (let ([tmp 5] [other 6]) (swap tmp other)) 87

48 How Lexical Scope Works (More Precisely) (let ([tmp 5] [other 6]) (swap tmp other)) (let ([tmp 0 5] [other 0 6]) (swap tmp 0 other 0 )) To parse let, rename bindings by adding a subscript 88

49 How Lexical Scope Works (More Precisely) (let ([tmp 5] [other 6]) (swap tmp other)) (let ([tmp 0 5] [other 0 6]) (swap tmp 0 other 0 )) To parse let, rename bindings by adding a subscript To parse quote, drop the subscript (let ([x 1]) 'x) (let ([x 1 1]) 'x 1 ) (let ([x 1 1]) 'x) 89

50 How Lexical Scope Works (More Precisely) (let ([tmp 5] [other 6]) (swap tmp other)) (let ([tmp 0 5] [other 0 6]) (swap tmp 0 other 0 )) (let ([tmp 0 5] [other 0 6]) (let 1 ([tmp 1 other 0 ]) (set! 1 other 0 tmp 0 ) (set! 1 tmp 0 tmp 1 ))) Mark superscripts on introduced identifiers 90

51 How Lexical Scope Works (More Precisely) (let ([tmp 5] [other 6]) (swap tmp other)) (let ([tmp 0 5] [other 0 6]) (swap tmp 0 other 0 )) (let ([tmp 0 5] [other 0 6]) (let 1 ([tmp 1 other 0 ]) (set! 1 other 0 tmp 0 ) (set! 1 tmp 0 tmp 1 ))) (let ([tmp 0 5] [other 0 6]) (let 1 ([tmp 2 other 0 ]) (set! 1 other 0 tmp 0 ) (set! 1 tmp 0 tmp 2 ))) Rename for let but only where superscript marks match 91

52 How Lexical Scope Works (More Precisely) (let ([tmp 5] [other 6]) (swap tmp other)) (let ([tmp 0 5] [other 0 6]) (swap tmp 0 other 0 )) (let ([tmp 0 5] [other 0 6]) (let 1 ([tmp 1 other 0 ]) (set! 1 other 0 tmp 0 ) (set! 1 tmp 0 tmp 1 ))) (let ([tmp 0 5] [other 0 6]) (let 1 ([tmp 2 other 0 ]) (set! 1 other 0 tmp 0 ) (set! 1 tmp 0 tmp 2 ))) Introductions marked with fresh superscript Matching marks renamed with fresh subscript 92

53 How Lexical Scope Works (More Precisely) (let ([set! 5] [let 6]) (swap set! let)) 93

54 How Lexical Scope Works (More Precisely) (let ([set! 5] [let 6]) (swap set! let)) (let ([let 0 5] [set! 0 6]) (swap let 0 set! 0 )) 94

55 How Lexical Scope Works (More Precisely) (let ([set! 5] [let 6]) (swap set! let)) (let ([let 0 5] [set! 0 6]) (swap let 0 set! 0 )) (let ([let 0 5] [set 0 6]) (let 1 ([tmp 1 set! 0 ]) (set! 1 let 0 set! 0 ) (set! 1 let 0 tmp 1 ))) 95

56 How Lexical Scope Works (More Precisely) (let ([set! 5] [let 6]) (swap set! let)) (let ([let 0 5] [set! 0 6]) (swap let 0 set! 0 )) (let ([let 0 5] [set 0 6]) (let 1 ([tmp 1 set! 0 ]) (set! 1 let 0 set! 0 ) (set! 1 let 0 tmp 1 ))) (let ([set! 0 5] [let 0 6]) (let 1 ([tmp 2 let 0 ]) (set! 1 let 0 set! 0 ) (set! 1 set! 0 tmp 2 ))) Superscript mark is not a rename: let 1 refers to let 96

57 Representing Code #'lambda syntax-object datum srcloc context 'lambda file.ss:1:13 { mark 3, rename tmp 2 to tmp 1, lambda = kernel,... } 97

58 Representing Code #'(lambda (x) x) syntax-object datum srcloc context ( syntax-object datum srcloc context syntax-object datum srcloc context syntax-object datum srcloc context ) file.ss:1:12 { mark 3, rename tmp 2 to tmp 1, lambda = kernel,... } 98

59 Examples Lisp-Style Macros Scheme Macros and Lexical Scope PLT Scheme Macros Source (... (...)...) S-expression function args body AST References and Related Work 99

60 Representing an AST An AST is represented by a syntax object define doc apply bold ("Hi") = (define-values (doc) (#%app bold '"Hi")) 100

61 Representing an AST mod ::= (module id name-id (#%plain-module-begin mod-form...)) mod-form ::= expr (#%provide spec...) (define-values (id...) expr) (define-syntaxes (id...) expr) (define-values-for-syntax (id...) expr) (#%require raw-require-spec...) expr ::= id (#%plain-lambda formals expr...+) (case-lambda (formals expr...+)...) (if expr expr expr) (begin expr...+) (begin0 expr expr...) (let-values (((id...) expr)...) expr...+) (letrec-values (((id...) expr)...) expr...+) (set! id expr) (quote datum) (quote-syntax datum) (with-continuation-mark expr expr expr) (#%plain-app expr...+) (#%top. id) (#%variable-reference. global) formals ::= (id...) (id...+. id) id 101

62 (module m scheme (define x 3) (+ x 1)) Implicit Keywords Demo: Lazy Scheme, Beginner Scheme (+ 1 2) (#%app + 1 2) (#%app + (#%datum 1) (#%datum 2)) (#%app + '1 '2) (module m scheme (#%module-begin (define x 3) (+ x 1))) Demo: Scheme, Scribble 102

63 Explicit Expansion For tools that manipulate whole programs: expand : syntax -> syntax For macro transformers: local-expand : syntax... -> syntax... and extra arguments to say where to stop 103

64 Explicit Expansion (define-syntax-rule (thunk body) (lambda () body)) (class object% (define/public me (thunk this))...) Copy (define-syntax class (lambda (stx)... (local-expand #'method 'expression (list #'lambda...))...)) 104

65 Internal Definition Contexts Demo: define-package intdef #'defn-or-expr #'defn-or-expr #'defn-or-expr local-expand install definition #'(define id...) #'expr #'(define id...) #'expr #'(define id...) #'expr 105

66 Internal Definition Contexts (define-package p (y) (define x 10) (define y x)) syntax-object datum srcloc context 'x file.ss:1:8 { mark 3, { rename x to x 5,...}, rename tmp 2 to tmp 1, lambda = kernel,... } 106

67 Transformer Bindings (define-package Demo: provide a package p...) (open-package p)? (define-package p...) (define-syntax p (make-package...)) (open-package p)... #,(syntax-local-value #'p)

68 Transformer Bindings Even syntax pattern variables are implemented with macros (syntax-case stx () [(form id expr)... #'id...]) (let ([m (match-syntax stx...)]) (define-syntax form (make-pattern m 0)) (define-syntax id (make-pattern m 1)) (define-syntax expr (make-pattern m 2)) #,(syntax-local-value #'id)......) Primitives include quote-syntax, syntax-e, datum->syntax 108

69 Fixed Point New forms can have their own expanders (define-match-expander polar...) (match v [(polar mag theta)...]) New forms can have compile-time functions module and syntax-local-lift-expression set! and make-set!-transformer

70 Examples Lisp-Style Macros Scheme Macros and Lexical Scope PLT Scheme Macros References and Related Work 110

71 Lisp Macros origin Hart MACRO Definitions for LISP AI Project Memo 57, 1963 current Steele Common Lisp: The Language

72 Scheme Macros hygiene Kohlbecker, Friedman, Felleisen, and Duba Hygienic Macro Expansion LFP 1986 patterns Clinger and Rees Macros That Work POPL 1991 lexical scope Dybvig, Hieb, and Bruggeman Syntactic Abstraction in Scheme Lisp and Symbolic Computation 1993 splicing scope phases Waddell and Dybvig Extending the Scope of Syntactic Abstraction POPL 1999 Flatt Composable and Compilable Macros ICFP

73 Lisp/Scheme Macros without Parentheses lisp Shalit, Moon, and Starbuck The Dylan Reference Manual 1996 scheme Baker and Hsieh Maya: Multiple-dispatch Syntax Extension in Java PLDI 2002, Utah MS Thesis 113

74 Language Construction environments Reps and Teitelbaum The Synthesizer Generator 1988 more parsing Heering, Klint, et al. ASF+SDF Meta-Environment 1984 PEGs Ford Parsing Expression Grammars 2004 compiler Cox, Bergan, Clements, Kaashoek, and Kohler Xoc, An Extension-Oriented Compiler ASPLOS

75 Current Work at Utah Jon Rafkind: Honu Chongkai Zhu: ML and DrScheme Kevin Atkinson: C 115

76 Lisp A language should be extensible within itself, with the full language available for implementing extensions. Scheme Syntax objects for language extension should be lexically scoped, as opposed to mere source text. PLT Scheme A language should allow control over the starting point and access to the expander to enable entirely new languages, not just mere extensions. 116

Scheme-Style Macros: Patterns and Lexical Scope

Scheme-Style Macros: Patterns and Lexical Scope Scheme-Style Macros: Patterns and Lexical Scope Matthew Flatt University of Utah 1 Why Macros? Language designers have to stop somewhere (544 pages) No language can provide every possible useful construct

More information

Why Macros? Scheme-Style Macros: Patterns and Lexical Scope. Macros versus Arbitrary Program Generators. Macros versus Arbitrary Program Generators

Why Macros? Scheme-Style Macros: Patterns and Lexical Scope. Macros versus Arbitrary Program Generators. Macros versus Arbitrary Program Generators Why Macros? Scheme-Style Macros: Patterns and Lexical Scope Language designers have to stop somewhere Matthew Flatt University of Utah (544 pages) No language can provide every possible useful construct

More information

Macros that Work Together

Macros that Work Together Under consideration for publication in J. Functional Programming 1 Macros that Work Together Compile-Time Bindings, Partial Expansion, and Definition Contexts Matthew Flatt 1, Ryan Culpepper 1, David Darais

More information

Honu: A syntactically extensible language

Honu: A syntactically extensible language Honu: A syntactically extensible language Jon Rafkind 0 and Matthew Flatt 1 University of Utah rafkind@cs.utah.edu mflatt@cs.utah.edu Abstract. Honu is a new language that contains a system for extending

More information

Macros that Work Together

Macros that Work Together JFP 22 (2): 181 216, 2012. c Cambridge University Press 2012 doi:10.1017/s0956796812000093 181 Macros that Work Together Compile-time bindings, partial expansion, and definition contexts MATTHEW FLATT,

More information

Syntactic Abstraction in Component Interfaces

Syntactic Abstraction in Component Interfaces Syntactic Abstraction in Component Interfaces Ryan Culpepper 1, Scott Owens 2, and Matthew Flatt 2 1 Northeastern University (ryanc@ccs.neu.edu) 2 University of Utah ([sowens, mflatt]@cs.utah.edu) Abstract.

More information

Languages as Libraries

Languages as Libraries Languages as Libraries or, implementing the next 700 programming languages Sam Tobin-Hochstadt Vincent St-Amour Ryan Culpepper Matthew Flatt Matthias Felleisen PLT @ Northeastern & Utah June 6, 2011 PLDI

More information

Racket: Macros. Advanced Functional Programming. Jean-Noël Monette. November 2013

Racket: Macros. Advanced Functional Programming. Jean-Noël Monette. November 2013 Racket: Macros Advanced Functional Programming Jean-Noël Monette November 2013 1 Today Macros pattern-based macros Hygiene Syntax objects and general macros Examples 2 Macros (According to the Racket Guide...)

More information

Binding as Sets of Scopes

Binding as Sets of Scopes Binding as Sets of Scopes Artifact Matthew Flatt University of Utah, USA mflatt@cs.utah.edu * POPL * Consistent * Complete * Well Documented * Easy to Reuse * Evaluated * AEC * Abstract Our new macro expander

More information

Languages as Libraries

Languages as Libraries Languages as Libraries or, implementing the next 700 programming languages Sam Tobin-Hochstadt PLT @ Northeastern University May 11, 2011 MIT 1 A domain specific language is the ultimate abstraction. Paul

More information

A Few Principles of Macro Design

A Few Principles of Macro Design A Few Principles of Macro Design David Herman Northeastern University dherman@ccs.neu.edu David Van Horn Brandeis University dvanhorn@cs.brandeis.edu Abstract Hygiene facilitates the implementation of

More information

SYNTACTIC EXTENSION FOR LANGUAGES WITH IMPLICITLY DELIMITED AND INFIX SYNTAX

SYNTACTIC EXTENSION FOR LANGUAGES WITH IMPLICITLY DELIMITED AND INFIX SYNTAX SYNTACTIC EXTENSION FOR LANGUAGES WITH IMPLICITLY DELIMITED AND INFIX SYNTAX by Jon Rafkind A dissertation submitted to the faculty of The University of Utah in partial fulfillment of the requirements

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 7 Wouter Swierstra 1 Last time Relating evaluation and types How to handle variable binding in embedded languages? 2 DSLs: approaches A stand-alone DSL typically

More information

Hygiene for the Unhygienic

Hygiene for the Unhygienic Hygiene for the Unhygienic Hygiene-Compatible Macros in an Unhygienic Macro System Pascal Costanza and Theo D Hondt (Vrije Universiteit Brussel Pascal.Costanza@vub.ac.be and Theo.D Hondt@vub.ac.be) Abstract:

More information

From Macrogeneration to Syntactic Abstraction

From Macrogeneration to Syntactic Abstraction From Macrogeneration to Syntactic Abstraction R. Kent Dybvig (dyb@cs.indiana.edu) Indiana University Computer Science Department Lindley Hall 215, Bloomington, IN 47408, USA October 1999 Abstract. In his

More information

Binding as Sets of Scopes

Binding as Sets of Scopes Binding as Sets of Scopes Abstract Our new macro expander for Racket builds on a novel approach to hygiene. Instead of basing macro expansion on variable renamings that are mediated by expansion history,

More information

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8 Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

More information

Submodules in Racket

Submodules in Racket Submodules in Racket You Want it When, Again? Matthew Flatt PLT and University of Utah mflatt@cs.utah.edu Abstract In an extensible programming language, programmers write code that must run at different

More information

Dissertation Proposal

Dissertation Proposal Dissertation Proposal Version 2.0 Jon Rafkind June 14, 2011 1 1 Introduction Thesis: Semantic macro systems are feasible and useful for typed languages with rich syntactic structure. Many existing languages

More information

Syntax: Meta-Programming Helpers

Syntax: Meta-Programming Helpers Syntax: Meta-Programming Helpers Version 5.0.1 August 3, 2010 1 Contents 1 Syntax Object Helpers 5 1.1 Deconstructing Syntax Objects........................ 5 1.2 Matching Fully-Expanded Expressions....................

More information

From Macros to Reusable Generative. Rice University. Seattle University. Seattle, WA , USA

From Macros to Reusable Generative. Rice University. Seattle University. Seattle, WA , USA From Macros to Reusable Generative Programming? Shriram Krishnamurthi 1, Matthias Felleisen 1, and Bruce F. Duba 2 1 Department of Computer Science Rice University Houston, TX 77005-1892, USA 2 Department

More information

Maya: Multiple-Dispatch Syntax Extension in Java. Jason Baker and Wilson C. Hsieh University of Utah

Maya: Multiple-Dispatch Syntax Extension in Java. Jason Baker and Wilson C. Hsieh University of Utah Maya: Multiple-Dispatch Syntax Extension in Java Jason Baker and Wilson C. Hsieh University of Utah Example java.util.vector v; v.elements().foreach(string st) { /* */ } Maya code for (Enumeration enum$

More information

xtc Robert Grimm Making C Safely Extensible New York University

xtc Robert Grimm Making C Safely Extensible New York University xtc Making C Safely Extensible Robert Grimm New York University The Problem Complexity of modern systems is staggering Increasingly, a seamless, global computing environment System builders continue to

More information

Functional Languages. Hwansoo Han

Functional Languages. Hwansoo Han Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm

More information

An Optimized R5RS Macro Expander. Sean Reque

An Optimized R5RS Macro Expander. Sean Reque An Optimized R5RS Macro Expander Sean Reque A thesis submitted to the faculty of Brigham Young University in partial fulfillment of the requirements for the degree of Master of Science Jay McCarthy, Chair

More information

Extensible Pattern Matching

Extensible Pattern Matching Extensible Pattern Matching Sam Tobin-Hochstadt PLT @ Northeastern University IFL, September 3, 2010 Extensible Pattern Matching in an Extensible Language Sam Tobin-Hochstadt PLT @ Northeastern University

More information

Chapter 11 :: Functional Languages

Chapter 11 :: Functional Languages Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative

More information

Debugging Macros. Ryan Culpepper. Matthias Felleisen. Abstract. 1. The Power of Macros. Northeastern University

Debugging Macros. Ryan Culpepper. Matthias Felleisen. Abstract. 1. The Power of Macros. Northeastern University Debugging Macros Ryan Culpepper Northeastern University ryanc@ccs.neu.edu Matthias Felleisen Northeastern University matthias@ccs.neu.edu Abstract Over the past two decades, Scheme macros have evolved

More information

Informal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility

Informal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility Informal Semantics of Data semantic specification names (identifiers) attributes binding declarations scope rules visibility 1 Ways to Specify Semantics Standards Documents (Language Definition) Language

More information

Creating Languages in Racket

Creating Languages in Racket Article development led by queue.acm.org Sometimes you just have to make a better mousetrap. By Matthew Flatt Creating Languages in Racket doi:10.1145/2063176.2063195 Racket is both a programming language

More information

Type Inference Systems. Type Judgments. Deriving a Type Judgment. Deriving a Judgment. Hypothetical Type Judgments CS412/CS413

Type Inference Systems. Type Judgments. Deriving a Type Judgment. Deriving a Judgment. Hypothetical Type Judgments CS412/CS413 Type Inference Systems CS412/CS413 Introduction to Compilers Tim Teitelbaum Type inference systems define types for all legal programs in a language Type inference systems are to type-checking: As regular

More information

Functional Programming

Functional Programming Functional Programming CS331 Chapter 14 Functional Programming Original functional language is LISP LISt Processing The list is the fundamental data structure Developed by John McCarthy in the 60 s Used

More information

Implicit Phasing for R6RS Libraries

Implicit Phasing for R6RS Libraries Implicit Phasing for R6RS Libraries Abdulaziz Ghuloum and R. Kent Dybvig Department of Computer Science, Indiana University, Bloomington, IN 47408 {aghuloum,dyb}@cs.indiana.edu Abstract The forthcoming

More information

CSCE 314 Programming Languages. Type System

CSCE 314 Programming Languages. Type System CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be

More information

Adapting Scheme-Like Macros to a C-Like Language

Adapting Scheme-Like Macros to a C-Like Language Adapting Scheme-Like Macros to a C-Like Language Kevin Atkinson, Matthew Flatt University of Utah 1 ZL Adopts a Scheme-like approach to build C++ from a C like core Why C? The system's programming language

More information

Title. Authors. Status. 1. Abstract. 2. Rationale. 3. Specification. R6RS Syntax-Case Macros. Kent Dybvig

Title. Authors. Status. 1. Abstract. 2. Rationale. 3. Specification. R6RS Syntax-Case Macros. Kent Dybvig Title R6RS Syntax-Case Macros Authors Kent Dybvig Status This SRFI is being submitted by a member of the Scheme Language Editor s Committee as part of the R6RS Scheme standardization process. The purpose

More information

Revised 5 Report on the Algorithmic Language Scheme

Revised 5 Report on the Algorithmic Language Scheme HIGHER-ORDER AND SYMBOLIC COMPUTATION 11, 7 105 (1998) Revised 5 Report on the Algorithmic Language Scheme H. ABELSON, R.K. DYBVIG, C.T. HAYNES, G.J. ROZAS, N.I. ADAMS IV, D.P. FRIEDMAN, E. KOHLBECKER,

More information

An Implementation of A Hygienic Syntactic Macro System for JavaScript: A Preliminary Report

An Implementation of A Hygienic Syntactic Macro System for JavaScript: A Preliminary Report An Implementation of A Hygienic Syntactic Macro System for JavaScript: A Preliminary Report Hiroshi Arai Department of Mathematical and Computing Science, Tokyo Institute of Technology harai6@is.titech.ac.jp

More information

CS 360 Programming Languages Interpreters

CS 360 Programming Languages Interpreters CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like

More information

Functional Programming. Big Picture. Design of Programming Languages

Functional Programming. Big Picture. Design of Programming Languages Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics

More information

A Stepper for Scheme Macros

A Stepper for Scheme Macros A Stepper for Scheme Macros Ryan Culpepper Northeastern University ryanc@ccs.neu.edu Matthias Felleisen Northeastern University matthias@ccs.neu.edu Abstract Even in the days of Lisp s simple defmacro

More information

Macro Debugger. Version 5.1. Ryan Culpepper. February 14, 2011

Macro Debugger. Version 5.1. Ryan Culpepper. February 14, 2011 Macro Debugger Version 5.1 Ryan Culpepper February 14, 2011 The macro-debugger collection contains two tools: a stepper for macro expansion and a standalone syntax browser. The macro stepper shows the

More information

Some Naughty Bits. Jeremy Brown. January 7-8, 2003

Some Naughty Bits. Jeremy Brown. January 7-8, 2003 Advanced Scheme Techniques Some Naughty Bits Jeremy Brown January 7-8, 2003 Page 1 Jeremy H. Brown January 7-8, 2003 Acknowledgements Jonathan Bachrach, Alan Bawden, Chris Hanson, Neel Krishnaswami, and

More information

The Environment Model. Nate Foster Spring 2018

The Environment Model. Nate Foster Spring 2018 The Environment Model Nate Foster Spring 2018 Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax: BNF Formal semantics: dynamic: small-step substitution model static semantics

More information

The Environment Model

The Environment Model The Environment Model Prof. Clarkson Fall 2017 Today s music: Selections from Doctor Who soundtracks by Murray Gold Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax: BNF

More information

Functional Programming. Pure Functional Languages

Functional Programming. Pure Functional Languages Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure

More information

Scheme: Expressions & Procedures

Scheme: Expressions & Procedures Scheme: Expressions & Procedures CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, March 31, 2017 Glenn G. Chappell Department of Computer Science University

More information

A Self-Hosting Evaluator using HOAS

A Self-Hosting Evaluator using HOAS A Self-Hosting Evaluator using HOAS A Scheme Pearl Eli Barzilay Northeastern University eli@barzilay.org Abstract We demonstrate a tiny, yet non-trivial evaluator that is powerful enough to run practical

More information

Implementing R7RS on an R6RS Scheme system

Implementing R7RS on an R6RS Scheme system Implementing R7RS on an R6RS Scheme system Takashi Kato Bell ID B.V. t.kato@bellid.com Abstract The Scheme language has three major standards; Revised 5 Report on the Algorithmic language Scheme (R5RS)

More information

hexpressioni ::= hvariablei j hself evaluating literali j (quote hdatumi) j (lambda (hvariablei*) hexpressioni + ) j (if hexpressioni hexpressioni hex

hexpressioni ::= hvariablei j hself evaluating literali j (quote hdatumi) j (lambda (hvariablei*) hexpressioni + ) j (if hexpressioni hexpressioni hex Expansion-Passing Style: A General Macro Mechanism* R. Kent Dybvig, Daniel P. Friedman, Christopher T. Haynes Abstract The traditional Lisp macro expansion facility inhibits several important forms of

More information

Little Languages and their Programming Environments

Little Languages and their Programming Environments Little Languages and their Programming Environments John Clements 1 Paul T. Graunke 1 Shriram Krishnamurthi 2 Matthias Felleisen 1 1 Department of Computer Science Rice University Houston, TX 77005-1892

More information

Macros. Pat Hanrahan. CS448h Fall 2015

Macros. Pat Hanrahan. CS448h Fall 2015 Macros Pat Hanrahan CS448h Fall 2015 Macro Definitions in Lisp Timothy Harris Abstract In LISP 1.5 special forms are used for three logically separate purposes: a) to reach the alist, b) to allow functions

More information

Functional Programming. Pure Functional Programming

Functional Programming. Pure Functional Programming Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

More information

Procedures. EOPL3: Section 3.3 PROC and App B: SLLGEN

Procedures. EOPL3: Section 3.3 PROC and App B: SLLGEN Procedures EOPL3: Section 3.3 PROC and App B: SLLGEN The PROC language Expression ::= proc (Identifier) Expression AST: proc-exp (var body) Expression ::= (Expression Expression) AST: call-exp (rator rand)

More information

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson 6.184 Lecture 4 Interpretation Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson 1 Interpretation Parts of an interpreter Arithmetic calculator

More information

Refining Syntactic Sugar: Tools for Supporting Macro Development

Refining Syntactic Sugar: Tools for Supporting Macro Development Refining Syntactic Sugar: Tools for Supporting Macro Development A dissertation presented by Ryan Culpepper to the Faculty of the Graduate School of the College of Computer and Information Science in partial

More information

6.037 Lecture 4. Interpretation. What is an interpreter? Why do we need an interpreter? Stages of an interpreter. Role of each part of the interpreter

6.037 Lecture 4. Interpretation. What is an interpreter? Why do we need an interpreter? Stages of an interpreter. Role of each part of the interpreter 6.037 Lecture 4 Interpretation Interpretation Parts of an interpreter Meta-circular Evaluator (Scheme-in-scheme!) A slight variation: dynamic scoping Original material by Eric Grimson Tweaked by Zev Benjamin,

More information

UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing: A preprocessor may allow a

More information

Programming Language Pragmatics

Programming Language Pragmatics Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott Historical Origins The imperative and functional models grew out of work undertaken Alan Turing, Alonzo Church, Stephen

More information

A Comparison of Designs for Extensible and Extension-Oriented Compilers. Austin T. Clements

A Comparison of Designs for Extensible and Extension-Oriented Compilers. Austin T. Clements A Comparison of Designs for Extensible and Extension-Oriented Compilers by Austin T. Clements S.B. in Computer Science and Engineering Massachusetts Institute of Technology (2006) Submitted to the Department

More information

Publications related to Chez Scheme

Publications related to Chez Scheme Publications related to Chez Scheme [1] Andrew W. Keep and R. Kent Dybvig. Automatic cross-library optimization. In Scheme 2013: Workshop on Scheme and Functional Programming, 2013. Describes how Chez

More information

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University Functional Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Historical Origins 2 The imperative and functional models grew out of work

More information

CS 415 Midterm Exam Spring 2002

CS 415 Midterm Exam Spring 2002 CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming

More information

Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003

Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003 Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003 CS 314, LS, LTM: Functional Programming 1 Scheme A program is an expression to be evaluated (in

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Syntactic Abstraction in Scheme

Syntactic Abstraction in Scheme LISP AND SYMBOLIC COMPUTATION: An International Journal, 5:4, 295 326, 1992 c 1992 Kluwer Academic Publishers Manufactured in The Netherlands Syntactic Abstraction in Scheme R. KENT DYBVIG (dyb@cs.indiana.edu)

More information

Functional Programming. Pure Functional Languages

Functional Programming. Pure Functional Languages Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure

More information

Little Languages and their Programming Environments

Little Languages and their Programming Environments Little Languages and their Programming Environments John Clements 1 Paul Graunke 1 Shriram Krishnamurthi 2 Matthias Felleisen 1 1 Department of Computer Science Rice University Houston, TX 77005-1892 contact:

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

More information

Meta-programming with Names and Necessity p.1

Meta-programming with Names and Necessity p.1 Meta-programming with Names and Necessity Aleksandar Nanevski Carnegie Mellon University ICFP, Pittsburgh, 05 October 2002 Meta-programming with Names and Necessity p.1 Meta-programming Manipulation of

More information

Maya: Multiple-Dispatch Syntax Extension in Java. Abstract

Maya: Multiple-Dispatch Syntax Extension in Java. Abstract Maya: Multiple-Dispatch Syntax Extension in Java Jason Baker and Wilson C. Hsieh UUCS-01-015 School of Computing University of Utah Salt Lake City, UT 84112 USA December 11, 2001 Abstract We have designed

More information

CSE341: Programming Languages Lecture 15 Macros. Zach Tatlock Winter 2018

CSE341: Programming Languages Lecture 15 Macros. Zach Tatlock Winter 2018 CSE341: Programming Languages Lecture 15 Macros Zach Tatlock Winter 2018 What is a macro A macro definition describes how to transform some new syntax into different syntax in the source language A macro

More information

What is a macro. CSE341: Programming Languages Lecture 15 Macros. Example uses. Using Racket Macros. Zach Tatlock Winter 2018

What is a macro. CSE341: Programming Languages Lecture 15 Macros. Example uses. Using Racket Macros. Zach Tatlock Winter 2018 What is a macro A macro definition describes how to transform some new syntax into different syntax in the source language CSE341: Programming Languages Lecture 15 Macros Zach Tatlock Winter 2018 A macro

More information

CS 11 Haskell track: lecture 1

CS 11 Haskell track: lecture 1 CS 11 Haskell track: lecture 1 This week: Introduction/motivation/pep talk Basics of Haskell Prerequisite Knowledge of basic functional programming e.g. Scheme, Ocaml, Erlang CS 1, CS 4 "permission of

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Vrije Universiteit Brussel Faculteit Wetenschappen. Continuation-Passing-Style as an Intermediate Representation for Compiling Scheme

Vrije Universiteit Brussel Faculteit Wetenschappen. Continuation-Passing-Style as an Intermediate Representation for Compiling Scheme VRIJE UNIVERSITEIT BRUSSEL Vrije Universiteit Brussel Faculteit Wetenschappen SCI EN T I A V INCERE T ENE BRA S Continuation-Passing-Style as an Intermediate Representation for Compiling Scheme Kris De

More information

Template Haskell based implementation of printf

Template Haskell based implementation of printf Lecture 19 Template Haskell based implementation of printf In the last lecture we saw a type class based solution to create functions that take variable number of arguments. Here we give a template haskell

More information

Urmas Tamm Tartu 2013

Urmas Tamm Tartu 2013 The implementation and optimization of functional languages Urmas Tamm Tartu 2013 Intro The implementation of functional programming languages, Simon L. Peyton Jones, 1987 Miranda fully lazy strict a predecessor

More information

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

5. Introduction to the Lambda Calculus. Oscar Nierstrasz 5. Introduction to the Lambda Calculus Oscar Nierstrasz Roadmap > What is Computability? Church s Thesis > Lambda Calculus operational semantics > The Church-Rosser Property > Modelling basic programming

More information

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018 CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018 Typical workflow concrete syntax (string) "(fn x => x + x) 4" Parsing Possible errors / warnings

More information

COMPILER DESIGN LECTURE NOTES

COMPILER DESIGN LECTURE NOTES COMPILER DESIGN LECTURE NOTES UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing:

More information

Racket: Modules, Contracts, Languages

Racket: Modules, Contracts, Languages Racket: Modules, Contracts, Languages Advanced Functional Programming Jean-Noël Monette November 2013 1 Today Modules are the way to structure larger programs in smaller pieces. Modules can import and

More information

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming t ::= x x. t t t Call-by-value big-step Operational Semantics terms variable v ::= values abstraction x.

More information

7. Introduction to Denotational Semantics. Oscar Nierstrasz

7. Introduction to Denotational Semantics. Oscar Nierstrasz 7. Introduction to Denotational Semantics Oscar Nierstrasz Roadmap > Syntax and Semantics > Semantics of Expressions > Semantics of Assignment > Other Issues References > D. A. Schmidt, Denotational Semantics,

More information

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation

More information

How to Write Seemingly Unhygienic and Referentially Opaque Macros with Syntax-rules

How to Write Seemingly Unhygienic and Referentially Opaque Macros with Syntax-rules How to Write Seemingly Unhygienic and Referentially Opaque Macros with Syntax-rules Oleg Kiselyov (oleg@okmij.org) Abstract. This paper details how folklore notions of hygiene and referential transparency

More information

THE UNIVERSITY OF CHICAGO OPERATIONAL SEMANTICS FOR SCHEME VIA TERM REWRITING A DISSERTATION SUBMITTED TO

THE UNIVERSITY OF CHICAGO OPERATIONAL SEMANTICS FOR SCHEME VIA TERM REWRITING A DISSERTATION SUBMITTED TO THE UNIVERSITY OF CHICAGO OPERATIONAL SEMANTICS FOR SCHEME VIA TERM REWRITING A DISSERTATION SUBMITTED TO THE FACULTY OF THE DIVISION OF THE PHYSICAL SCIENCES IN CANDIDACY FOR THE DEGREE OF MASTER OF SCIENCE

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages CS 314 Principles of Programming Languages Lecture 15: Review and Functional Programming Zheng (Eddy) Zhang Rutgers University March 19, 2018 Class Information Midterm exam forum open in Sakai. HW4 and

More information

Automatic Cross-Library Optimization

Automatic Cross-Library Optimization Automatic Cross-Library Optimization Andrew W. Keep University of Utah akeep@cs.utah.edu R. Kent Dybvig Cisco Systems Inc. dyb@cisco.com Abstract The library construct added to Scheme by the Revised 6

More information

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria CS152 Programming Language Paradigms Prof. Tom Austin, Fall 2014 Syntax & Semantics, and Language Design Criteria Lab 1 solution (in class) Formally defining a language When we define a language, we need

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions

More information

A Theory of Hygienic Macros

A Theory of Hygienic Macros A Theory of Hygienic Macros David Herman and Mitchell Wand College of Computer and Information Science Northeastern University Boston, MA 02115 {dherman,wand}@ccs.neu.edu Abstract. Hygienic macro systems

More information

Maya: Multiple-Dispatch Syntax Extension in Java

Maya: Multiple-Dispatch Syntax Extension in Java Maya: Multiple-Dispatch Syntax Extension in Java Jason Baker and Wilson C. Hsieh University of Utah ABSTRACT We have designed and implemented Maya, a version of Java that allows programmers to extend and

More information

Typed Scheme From Scripts to Programs. Sam Tobin-Hochstadt Northeastern University

Typed Scheme From Scripts to Programs. Sam Tobin-Hochstadt Northeastern University Typed Scheme From Scripts to Programs Sam Tobin-Hochstadt Northeastern University 1 The PL Renaissance 2 The PL Renaissance 3 The PL Renaissance 4 What s good These languages are interactive designed for

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics

More information

CST-402(T): Language Processors

CST-402(T): Language Processors CST-402(T): Language Processors Course Outcomes: On successful completion of the course, students will be able to: 1. Exhibit role of various phases of compilation, with understanding of types of grammars

More information

Organization of Programming Languages CS3200/5200N. Lecture 11

Organization of Programming Languages CS3200/5200N. Lecture 11 Organization of Programming Languages CS3200/5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Functional vs. Imperative The design of the imperative languages

More information

Kent Dybvig, Will Clinger, Matthew Flatt, Mike Sperber, and Anton van Straaten

Kent Dybvig, Will Clinger, Matthew Flatt, Mike Sperber, and Anton van Straaten R6RS Status Report Kent Dybvig, Will Clinger, Matthew Flatt, Mike Sperber, and Anton van Straaten February 24, 2006 1. Overview This status report describes the current state of the R 6 RS standardization

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information