Download presentation
Presentation is loading. Please wait.
1
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 Widespread … ……… … ……... Dylan Dylan Macro Mechamism M4 Unix Macro Preprocessor L A T E X T E X Macro Mechanism C C preprocessor, CPP C++ C++ Templates Scheme Scheme Macros Java/JTS The Jakarta Tool Suite … ………
2
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 “Macro” Webster’s( “macro” ) = Main Entry: 2 macro Pronunciation: 'ma-(")krO Function: noun Inflected Form(s): plural macros Etymology: short for macroinstruction Date: 1959 “a single computer instruction that stands for a sequence of operations”
3
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 The Setup compilation / 2) interpretation / analysis / … m: L+ L program. l + program. l 1) macro expansion You are programming in L…...but you wish you had construction m In fact: Macros give you exactly that!
4
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 MyJava enum { foo, bar, baz };... for (String s : list) { System.out.println("" + s); } static final int foo = 0; static final int bar = 1; static final int baz = 2;... Iterator i = list.iterator(); while (i.hasNext()) { String s = (String) i.next(); System.out.println("" + s); } Decl : enum... = {... } Stm : for... = {... } Java program Macros: MyJava Java MyJava program
5
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 Benefits Abstraction // language extension Consistency // modularity Encapsulation // hide complexity Code Reuse // Smsitis Genericity // uniform abstraction mechanism for (String s : list) { System.out.println(s); } for (String s : list) { System.out.println(s); } vs. “An excuse to invent languages and write compilers…” :) Iterator iterator = list.iterator(); while (iterator.hasNext()) { String s = (String) iterator.next(); System.out.println(s); } Iterator iterator = list.iterator(); while (iterator.hasNext()) { String s = (String) iterator.next(); System.out.println(s); }
6
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 Immensely Different Lexical Macros: Operate on token sequences: Syntactic Macros: Operate on parse trees: ()z + 1 * => square
7
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 Study Group: Pathway to “Speciale” Study Group “Macros” (5 ECTS) A B C … speciale synergy
8
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 Investigate macro languages: CPP, M4, T E X, Dylan, C++ Templates, Scheme, JTS, MS 2, … Identify relevant properties: Level of operation, body expansion time, order of expansion, … Macro Survey
9
) y + 1 * => square ( January 31, 2005MacrosClaus Brabrand y + 1 Speciale Ideas #1: Macro Survey #2: Macro System Generator #4: Parameterized Macros #7: Static Semantics (def/use) #19: Syntax Transformation (x: S T) #146: Grammar Toolkit …
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.