Generic Programming Galore Using D
|
|
- Luke McBride
- 6 years ago
- Views:
Transcription
1 Generic Programming Galore Using D Andrei Alexandrescu, PhD Research Scientist Facebook c 2011 Andrei Alexandrescu 1 / 33
2 37% off c 2011 Andrei Alexandrescu 2 / 33
3 Generic Programming c 2011 Andrei Alexandrescu 3 / 33
4 What is Generic Programming? c 2011 Andrei Alexandrescu 4 / 33
5 What is Generic Programming? Find most general algorithm representation Narrowest requirements Widest guarantees Big-O() encapsulation should be a crime No need to regress to hand-written code c 2011 Andrei Alexandrescu 4 / 33
6 What is Generic Programming? Find most general algorithm representation Narrowest requirements Widest guarantees Big-O() encapsulation should be a crime No need to regress to hand-written code Define types to implement said requirements c 2011 Andrei Alexandrescu 4 / 33
7 What is Generic Programming? Find most general algorithm representation Narrowest requirements Widest guarantees Big-O() encapsulation should be a crime No need to regress to hand-written code Define types to implement said requirements Leverage the algorithm for ultimate reuse c 2011 Andrei Alexandrescu 4 / 33
8 What is Generic Programming? Find most general algorithm representation Narrowest requirements Widest guarantees Big-O() encapsulation should be a crime No need to regress to hand-written code Define types to implement said requirements Leverage the algorithm for ultimate reuse... Profit! c 2011 Andrei Alexandrescu 4 / 33
9 What is Generic Programming? Find most general algorithm representation Narrowest requirements Widest guarantees Big-O() encapsulation should be a crime No need to regress to hand-written code Define types to implement said requirements Leverage the algorithm for ultimate reuse... Profit! Arguably one of the noblest endeavors of our métier c 2011 Andrei Alexandrescu 4 / 33
10 Generic Programming Write once, instantiate anywhere Specialized implementations welcome Prefers static type information and static expansion (macro style) Fosters strong mathematical underpinnings Minimizing assumptions common theme in math Tenuous relationship with binary interfaces Starts with algorithms, not interfaces or objects Premature encapsulation is the root of some derangement c 2011 Andrei Alexandrescu 5 / 33
11 Warmup: the dream min Should work at efficiency comparable to hand-written code Take variadic arguments: min(a, b,...) Avoid nonsensical calls min() and min(a) Work for all ordered types and conversions Decline incompatible types, without prejudice c 2011 Andrei Alexandrescu 6 / 33
12 First prototype auto min(l, R)(L lhs, R rhs) { return rhs < lhs? rhs : lhs; } auto a = min(x, y); This function is as efficient as any specialized, handwritten version (true genericity) Deduction for argument types and result type c 2011 Andrei Alexandrescu 7 / 33
13 Variadic arguments auto min(t...)(t x) { static if (x.length > 2) return min(min(x[0], x[1]), x[2.. $]); else return x[0] > x[1]? x[1] : x[0]; }... auto m = min(a + b, 100, c); x is not an array This is not classic recursion c 2011 Andrei Alexandrescu 8 / 33
14 Reject nonsensical calls auto min(t...)(t x) if (x.length > 1) {... } Rejects calls with 0 or 1 arguments Allows other overloads to take over, e.g. min element over a collection More work needed Only accept types with a valid intersection Only accept types comparable with < c 2011 Andrei Alexandrescu 9 / 33
15 Common type Task: Given a list of types, find the common type of all template CommonType(T...) { static if (T.length == 1) alias T[0] CommonType; else static if (is(typeof(1? T[0].init : T[1].init) U)) alias CommonType!(U, T[2.. $]) CommonType; else alias void CommonType; } // Usage static assert(is(commontype!(int, short, long) == long)); c 2011 Andrei Alexandrescu 10 / 33
16 Using CommonType auto min(t...)(t x) if (x.length > 1 && is(typeof(commontype!t.init < CommonType!T.init) == bool)) { static if (x.length > 2) return min(min(x[0], x[1]), x[2.. $]); else return x[0] > x[1]? x[1] : x[0]; } c 2011 Andrei Alexandrescu 11 / 33
17 How about min over many elements? auto min(r)(r range) if (isinputrange!r && is(typeof(range.front < range.front) == bool)) { auto result = range.front; range.popfront(); foreach (e; range) { if (e < result) result = e; } return result; } auto m = [ 1, 5, 2, 0, 7, 9 ].min(); Works over anything that can be iterated c 2011 Andrei Alexandrescu 12 / 33
18 How about argmin now? auto argmin(alias fun, R)(R r) if (isinputrange!r && is(typeof(fun(r.front) < fun(r.front)) == bool)) { auto result = r.front; auto cache = fun(result); r.popfront(); foreach (e; r) { auto cand = fun(e); if (cand > cache) continue; result = e; cache = cand; } return result; } c 2011 Andrei Alexandrescu 13 / 33
19 argmin auto s = ["abc", "a", "xz"]; auto m = s.argmin!((x) => x.length); Works on anything iterable and any predicate Predicate is passed by alias No loss of efficiency c 2011 Andrei Alexandrescu 14 / 33
20 The Generative Connection c 2011 Andrei Alexandrescu 15 / 33
21 Generative programming In brief: code that generates code Generic programming often requires algorithm specialization Specification often present in a DSL c 2011 Andrei Alexandrescu 16 / 33
22 Embedded DSLs Force into host language s syntax? c 2011 Andrei Alexandrescu 17 / 33
23 Embedded DSLs Formatted printing? c 2011 Andrei Alexandrescu 18 / 33
24 Embedded DSLs Formatted printing? Regular expressions? c 2011 Andrei Alexandrescu 18 / 33
25 Embedded DSLs Formatted printing? Regular expressions? EBNF? c 2011 Andrei Alexandrescu 18 / 33
26 Embedded DSLs Formatted printing? Regular expressions? EBNF? PEG? c 2011 Andrei Alexandrescu 18 / 33
27 Embedded DSLs Formatted printing? Regular expressions? EBNF? PEG? SQL? c 2011 Andrei Alexandrescu 18 / 33
28 Embedded DSLs Formatted printing? Regular expressions? EBNF? PEG? SQL?... Pasta for everyone! c 2011 Andrei Alexandrescu 18 / 33
29 Embedded DSLs Here: use with native grammar Process during compilation Generate D code accordingly c 2011 Andrei Alexandrescu 19 / 33
30 Compile-Time Evaluation A large subset of D available for compile-time evaluation ulong factorial(uint n) { ulong result = 1; foreach (i; 2.. n) result *= i; return result; }... auto f1 = factorial(10); // run-time static f2 = factorial(10); // compile-time c 2011 Andrei Alexandrescu 20 / 33
31 Code injection with mixin mixin("writeln(\"hello, world\");"); mixin(generatesomecode()); Not as glamorous as AST manipulation but darn effective Easy to understand and debug Now we have compile-time evaluation ANDmixin... c 2011 Andrei Alexandrescu 21 / 33
32 Wait a minute! c 2011 Andrei Alexandrescu 22 / 33
33 Example: bitfields in library struct A { int a; mixin(bitfields!( uint, "x", 2, int, "y", 3, uint, "z", 2, bool, "flag", 1)); } A obj; obj.x = 2; obj.z = obj.x; c 2011 Andrei Alexandrescu 23 / 33
34 Parser import pegged.grammar; // by Philippe Sigaud mixin(grammar(" Expr < Factor AddExpr* AddExpr < ( + / - ) Factor Factor < Primary MulExpr* MulExpr < Primary < Parens < ( Expr ) Number <~ [0-9]+ Variable <- Identifier ")); ( * / / ) Primary Parens / Number / Variable / - Primary c 2011 Andrei Alexandrescu 24 / 33
35 Usage // Parsing at compile-time: static parsetree1 = Expr.parse( " (3*x-5)*6"); pragma(msg, parsetree1.capture); // Parsing at run-time: auto parsetree2 = Expr.parse(readln()); writeln(parsetree2.capture); c 2011 Andrei Alexandrescu 25 / 33
36 Scaling up 1000 lines of D grammar 3000 lines D parser c 2011 Andrei Alexandrescu 26 / 33
37 Highly integrated lex+yacc c 2011 Andrei Alexandrescu 27 / 33
38 What about regexen? c 2011 Andrei Alexandrescu 28 / 33
39 Compile-time regular expressions GSoC project by Dmitry Olshansky: FReD Fully UTF capable, no special casing for ASCII Two modes sharing the same backend: auto r1 = regex("^.*/([^/]+)/?$"); static r2 = ctregex!("^.*/([^/]+)/?$"); Run-time version uses intrinsics in a few places Static version generates specialized automaton, then compiles it c 2011 Andrei Alexandrescu 29 / 33
40
41 Summary c 2011 Andrei Alexandrescu 31 / 33
42 Summary Generic/generative programming long unattained promise D s angle Powerful base language Type manipulation Compile-time evaluation Code generation c 2011 Andrei Alexandrescu 32 / 33
43 Grill the Speaker! More about ranges? Thought the talk was boring Intriguing! He lost me atmixin Awesome Went over my head Meh Iwonder how I can implement binary search What s for dinner? Accent is bothersome Real programmers use C Must... control... fist... of... death... c 2011 Andrei Alexandrescu 33 / 33
Introduction. Three Cool Things About D code::dive Conference, Wrocław, Poland. Andrei Alexandrescu, Ph.D.
Three Cool Things About D code::dive Conference, Wrocław, Poland Andrei Alexandrescu, Ph.D. andrei@erdani.com Nov 5, 2015 2015- Andrei Alexandrescu. Do not redistribute. 1 / 41 Introduction 2015- Andrei
More informationD Programming Language: The Sudden
D Programming Language: The Sudden Andrei Alexandrescu, Ph.D. Research Scientist, Facebook aa@fb.com YOW 2014 c 2014 Andrei Alexandrescu. 1 / 44 Introduction c 2014 Andrei Alexandrescu. 2 / 44 Introduction
More informationThree Cool Things About D
Three Cool Things About D Andrei Alexandrescu Research Scientist Facebook c 2010 Andrei Alexandrescu 1 / 47 What s the Deal? c 2010 Andrei Alexandrescu 2 / 47 PL Landscape Systems/Productivity languages
More informationLL(k) Parsing. Predictive Parsers. LL(k) Parser Structure. Sample Parse Table. LL(1) Parsing Algorithm. Push RHS in Reverse Order 10/17/2012
Predictive Parsers LL(k) Parsing Can we avoid backtracking? es, if for a given input symbol and given nonterminal, we can choose the alternative appropriately. his is possible if the first terminal of
More informationD Programming Language
Group 14 Muazam Ali Anil Ozdemir D Programming Language Introduction and Why D? It doesn t come with a religion this is written somewhere along the overview of D programming language. If you actually take
More informationPry - pragmatic parser combinators in D. Dmitry Olshansky Dconf 2017
Pry - pragmatic parser combinators in D Dmitry Olshansky Dconf 2017 Setting up the stage For me it all started out with std.regex in 2011... aimed just to plug a hole in the ecosystem actually got us in
More informationDesign by Introspection
Design by Introspection Andrei Alexandrescu, Ph.D. 2017-11-03 2017 Andrei Alexandrescu, Ph.D. Do not redistribute. 1 / 40 What s the Deal?? 2017 Andrei Alexandrescu, Ph.D. Do not redistribute. 2 / 40 Initial
More informationSemantic Analysis. Lecture 9. February 7, 2018
Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationECE251 Midterm practice questions, Fall 2010
ECE251 Midterm practice questions, Fall 2010 Patrick Lam October 20, 2010 Bootstrapping In particular, say you have a compiler from C to Pascal which runs on x86, and you want to write a self-hosting Java
More informationCMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics
Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End
More informationCSCE 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 informationCS115 - Module 4 - Compound data: structures
Fall 2017 Reminder: if you have not already, ensure you: Read How to Design Programs, sections 6-7, omitting 6.2, 6.6, 6.7, and 7.4. Compound data It often comes up that we wish to join several pieces
More informationSemester Review CSC 301
Semester Review CSC 301 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out: l l l l Imperative Languages l assignment and iteration
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCompiler Construction
Compiler Construction Lecture 4 - Context-Free Grammars 2003 Robert M. Siegfried All rights reserved A few necessary definitions Parse -vt,to resolve (as a sentence) into component parts of speech and
More informationHaskell and C++ Template Metaprogramming. Bartosz Milewski
Haskell and C++ Template Metaprogramming Bartosz Milewski Why Haskell? Easy syntax Almost one-to-one match with C++ TMP Differences Runtime vs. compile-time Regular data vs. types Plan Functions and Metafunctions
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationSeptember 10,
September 10, 2013 1 Bjarne Stroustrup, AT&T Bell Labs, early 80s cfront original C++ to C translator Difficult to debug Potentially inefficient Many native compilers exist today C++ is mostly upward compatible
More informationCSE 130 Programming Language Principles & Paradigms Lecture # 5. Chapter 4 Lexical and Syntax Analysis
Chapter 4 Lexical and Syntax Analysis Introduction - Language implementation systems must analyze source code, regardless of the specific implementation approach - Nearly all syntax analysis is based on
More informationTail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)
CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)
More informationUsing Enum Structs as Bitfields
New York C++ Developers Group July 12, 2016 Using Enum Structs as Bitfields Presentation by Jon Kalb Based on an article in Overload magazine by Anthony Williams 1 What do these have in common?! explicit
More informationThe Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured
Introduction p. xxix The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Language p. 6 C Is a Programmer's Language
More informationDebug C++ Without Running. Anastasia Kazakova
Debug C++ Without Running Anastasia Kazakova JetBrains @anastasiak2512 Agenda 1. Tricky C++ language. Show samples! 2. Seems to help but it doesn t. Why? Running / Debugging Static / dynamic code analysis
More informationInstantiation of Template class
Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double
More informationxtc 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 informationSyntax and Grammars 1 / 21
Syntax and Grammars 1 / 21 Outline What is a language? Abstract syntax and grammars Abstract syntax vs. concrete syntax Encoding grammars as Haskell data types What is a language? 2 / 21 What is a language?
More informationCPS 506 Comparative Programming Languages. Syntax Specification
CPS 506 Comparative Programming Languages Syntax Specification Compiling Process Steps Program Lexical Analysis Convert characters into a stream of tokens Lexical Analysis Syntactic Analysis Send tokens
More informationLanguages and Compilers
Principles of Software Engineering and Operational Systems Languages and Compilers SDAGE: Level I 2012-13 3. Formal Languages, Grammars and Automata Dr Valery Adzhiev vadzhiev@bournemouth.ac.uk Office:
More informationCSE 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 informationCrafting a Compiler with C (II) Compiler V. S. Interpreter
Crafting a Compiler with C (II) 資科系 林偉川 Compiler V S Interpreter Compilation - Translate high-level program to machine code Lexical Analyzer, Syntax Analyzer, Intermediate code generator(semantics Analyzer),
More informationThe Substitution Model
The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on
More informationCSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures
CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationCMSC 330: Organization of Programming Languages. Operational Semantics
CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged
More informationThere are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.
Programming, Data Structures and Algorithms Prof. Hema Murthy Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 49 Module 09 Other applications: expression tree
More informationLecture 3: Recursion; Structural Induction
15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion
More informationStream Computing using Brook+
Stream Computing using Brook+ School of Electrical Engineering and Computer Science University of Central Florida Slides courtesy of P. Bhaniramka Outline Overview of Brook+ Brook+ Software Architecture
More informationAn Introduction to Template Metaprogramming
An Introduction to Template Metaprogramming Barney Dellar Software Team Lead Toshiba Medical Visualisation Systems Caveat I decided to do this talk after getting thoroughly lost on the recent talk on SFINAE.
More informationFirst Midterm Exam CS164, Fall 2007 Oct 2, 2007
P a g e 1 First Midterm Exam CS164, Fall 2007 Oct 2, 2007 Please read all instructions (including these) carefully. Write your name, login, and SID. No electronic devices are allowed, including cell phones
More informationThe Substitution Model. Nate Foster Spring 2018
The Substitution Model Nate Foster Spring 2018 Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on single steps parser and lexer (in lab)
More informationC# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh
C# Fundamentals Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 1 2018/19 H-W. Loidl (Heriot-Watt Univ) F20SC/F21SC 2018/19
More informationChapter 4. Lexical and Syntax Analysis
Chapter 4 Lexical and Syntax Analysis Chapter 4 Topics Introduction Lexical Analysis The Parsing Problem Recursive-Descent Parsing Bottom-Up Parsing Copyright 2012 Addison-Wesley. All rights reserved.
More informationSection 2.4: Arguments with Quantified Statements
Section 2.4: Arguments with Quantified Statements In this section, we shall generalize the ideas we developed in Section 1.3 to arguments which involve quantified statements. Most of the concepts we shall
More informationObject-oriented Compiler Construction
1 Object-oriented Compiler Construction Extended Abstract Axel-Tobias Schreiner, Bernd Kühl University of Osnabrück, Germany {axel,bekuehl}@uos.de, http://www.inf.uos.de/talks/hc2 A compiler takes a program
More informationtemplate <typename T> // unless it s an unqualified pointer struct IsPtr<T *> { enum { r = true }; };
SFINAE Sono Buoni SFINAE In attempting to use function template argument deduction to select among a number of candidate function templates, a C++ compiler may attempt an instantiation that fails on one
More information4. Lexical and Syntax Analysis
4. Lexical and Syntax Analysis 4.1 Introduction Language implementation systems must analyze source code, regardless of the specific implementation approach Nearly all syntax analysis is based on a formal
More informationPoint-Free Templates
Point-Free Templates European LLVM Developers Meeting 2018 Andrew Gozillon, Dr. Paul Keir School of Engineering and Computing University of the West of Scotland, Paisley Campus April 17th, 2018 Introduction
More informationIntroduction to the D programming language. Marc Fuentes - SED
Introduction to the D programming language Marc Fuentes - SED Why an another language? Fortran (90) is fast, has nice array features, but I/O and objects are not very powerful Why an another language?
More informationIntroduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.
Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and
More informationBuilding Compilers with Phoenix
Building Compilers with Phoenix Parser Generators: ANTLR History of ANTLR ANother Tool for Language Recognition Terence Parr's dissertation: Obtaining Practical Variants of LL(k) and LR(k) for k > 1 PCCTS:
More informationLanguage Reference Manual simplicity
Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna
More informationExtending xcom. Chapter Overview of xcom
Chapter 3 Extending xcom 3.1 Overview of xcom xcom is compile-and-go; it has a front-end which analyzes the user s program, a back-end which synthesizes an executable, and a runtime that supports execution.
More information4. Lexical and Syntax Analysis
4. Lexical and Syntax Analysis 4.1 Introduction Language implementation systems must analyze source code, regardless of the specific implementation approach Nearly all syntax analysis is based on a formal
More informationWriting Evaluators MIF08. Laure Gonnord
Writing Evaluators MIF08 Laure Gonnord Laure.Gonnord@univ-lyon1.fr Evaluators, what for? Outline 1 Evaluators, what for? 2 Implementation Laure Gonnord (Lyon1/FST) Writing Evaluators 2 / 21 Evaluators,
More informationOverload Resolution. Ansel Sermersheim & Barbara Geller Amsterdam C++ Group March 2019
Ansel Sermersheim & Barbara Geller Amsterdam C++ Group March 2019 1 Introduction Prologue Definition of Function Overloading Determining which Overload to call How Works Standard Conversion Sequences Examples
More informationCSE 12 Abstract Syntax Trees
CSE 12 Abstract Syntax Trees Compilers and Interpreters Parse Trees and Abstract Syntax Trees (AST's) Creating and Evaluating AST's The Table ADT and Symbol Tables 16 Using Algorithms and Data Structures
More informationCS 230 Programming Languages
CS 230 Programming Languages 09 / 16 / 2013 Instructor: Michael Eckmann Today s Topics Questions/comments? Continue Syntax & Semantics Mini-pascal Attribute Grammars More Perl A more complex grammar Let's
More informationExtensible Java Pre-processor
Extensible Java Pre-processor National Institute of Advanced Industrial Science and Technology(AIST) Yuuji Ichisugi http://staff.aist.go.jp/y-ichisugi/ 2002/12/17 1 What is EPP? Language extension framework
More informationCOMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking
Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review
More informationMethods: A Deeper Look
1 2 7 Methods: A Deeper Look OBJECTIVES In this chapter you will learn: How static methods and variables are associated with an entire class rather than specific instances of the class. How to use random-number
More informationVariadic Templates. Andrei Alexandrescu Research Scientist Facebook. c 2012 Andrei Alexandrescu, Facebook. 1 / 34
Variadic Templates Andrei Alexandrescu Research Scientist Facebook c 2012 Andrei Alexandrescu, Facebook. 1 / 34 Twitter stream highlight Don t think I ll be able to stay up to see whatever Cthuloid-template-horror
More informationCS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)
CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going
More informationCERTIFICATE IN WEB PROGRAMMING
COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING
More informationComponent Programming in The D Programming Language. by Walter Bright
Component Programming in The D Programming Language by Walter Bright Reusable Software an axiom we all buy into it we all try to write reusable software The Reality 35 years of programming, and very little
More informationWAY MORE THAN YOU EVER WANTED TO KNOW ABOUT C++ TEMPLATES AND C++ TEMPLATE METAPROGRAMMING DYLAN KNUTSON, UCSD 13-17
WAY MORE THAN YOU EVER WANTED TO KNOW ABOUT C++ TEMPLATES AND C++ TEMPLATE METAPROGRAMMING DYLAN KNUTSON, UCSD 13-17 Creative Commons Attribution + Noncommercial WHO AM I Facebook Seattle s Core Systems/Infra
More informationDefining Languages GMU
Defining Languages CS463 @ GMU How do we discuss languages? We might focus on these qualities: readability: how well does a language explicitly and clearly describe its purpose? writability: how expressive
More informationC# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals
C# Types Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:
More informationModules, Structs, Hashes, and Operational Semantics
CS 152: Programming Language Paradigms Modules, Structs, Hashes, and Operational Semantics Prof. Tom Austin San José State University Lab Review (in-class) Modules Review Modules from HW 1 (in-class) How
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationLDC: The LLVM-based D Compiler
LDC: The LLVM-based D Compiler Using LLVM as backend for a D compiler Kai Nacke 02/02/14 LLVM devroom @ FOSDEM 14 Agenda Brief introduction to D Internals of the LDC compiler Used LLVM features Possible
More informationIndustrial Programming
Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 C# Types Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:
More informationImplementing Perl 6 Jonathan Worthington Dutch Perl Workshop 2008
Implementing Perl 6 Jonathan Worthington Dutch Perl Workshop 2008 I didn t know I was giving this talk until yesterday. I could have written my slides last night, but Guess what will be released at Christmas?*
More informationThe Parsing Problem (cont d) Recursive-Descent Parsing. Recursive-Descent Parsing (cont d) ICOM 4036 Programming Languages. The Complexity of Parsing
ICOM 4036 Programming Languages Lexical and Syntax Analysis Lexical Analysis The Parsing Problem Recursive-Descent Parsing Bottom-Up Parsing This lecture covers review questions 14-27 This lecture covers
More informationData Types. Every program uses data, either explicitly or implicitly to arrive at a result.
Every program uses data, either explicitly or implicitly to arrive at a result. Data in a program is collected into data structures, and is manipulated by algorithms. Algorithms + Data Structures = Programs
More informationCSE 401 Midterm Exam Sample Solution 2/11/15
Question 1. (10 points) Regular expression warmup. For regular expression questions, you must restrict yourself to the basic regular expression operations covered in class and on homework assignments:
More informationWelcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.
Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
More informationCSE341: 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 informationGreedy regular expression matching
Greedy regular expression matching Alain Frisch (ENS Paris) Luca Cardelli (MSR Cambridge) PLAN-X 2004 p.1/16 The matching problem Problem = project the structure of a regular expression on a flat sequence.
More informationCSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking
CSE450 Translation of Programming Languages Lecture 11: Semantic Analysis: Types & Type Checking Structure Project 1 - of a Project 2 - Compiler Today! Project 3 - Source Language Lexical Analyzer Syntax
More informationSyntax-Directed Translation. Lecture 14
Syntax-Directed Translation Lecture 14 (adapted from slides by R. Bodik) 9/27/2006 Prof. Hilfinger, Lecture 14 1 Motivation: parser as a translator syntax-directed translation stream of tokens parser ASTs,
More informationCSE 143: Computer Programming II Spring 2015 HW7: 20 Questions (due Thursday, May 28, :30pm)
CSE 143: Computer Programming II Spring 2015 HW7: 20 Questions (due Thursday, May 28, 2015 11:30pm) This program focuses on binary trees and recursion. Turn in the following files using the link on the
More informationCS 230 Programming Languages
CS 230 Programming Languages 10 / 16 / 2013 Instructor: Michael Eckmann Today s Topics Questions/comments? Top Down / Recursive Descent Parsers Top Down Parsers We have a left sentential form xa Expand
More informationCMPT 379 Compilers. Parse trees
CMPT 379 Compilers Anoop Sarkar http://www.cs.sfu.ca/~anoop 10/25/07 1 Parse trees Given an input program, we convert the text into a parse tree Moving to the backend of the compiler: we will produce intermediate
More informationPage. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team
Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Question No: 1 ( Marks: 2 ) Write a declaration statement for an array of 10
More information6.096 Introduction to C++
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.096 Lecture 3 Notes
More informationRYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 INSTRUCTIONS
RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 STUDENT ID: INSTRUCTIONS Please write your student ID on this page. Do not write it or your name
More informationGeneral Purpose Languages Should be Metalanguages. Jeremy G. Siek University of Colorado at Boulder
General Purpose Languages Should be Metalanguages Jeremy G. Siek University of Colorado at Boulder General Purpose vs. Domain Specific "Most programming languages are partly a way of expressing things
More informationDecaf Language Reference
Decaf Language Reference Mike Lam, James Madison University Fall 2016 1 Introduction Decaf is an imperative language similar to Java or C, but is greatly simplified compared to those languages. It will
More informationError Handling: SYNTAX
Error Handling: SYNTAX Basic Model Parse tree + w w S treep t 1 t 2 t 3 t n wp $ Cursors: treep & wp Error condition treep & wp are out of synchronisation Error recovery Re synch treep & wp Assumptions
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationExpansion statements. Version history. Introduction. Basic usage
Expansion statements Version history Document: P1306R0 Revises: P0589R0 Date: 08 10 2018 Audience: EWG Authors: Andrew Sutton (asutton@uakron.edu) Sam Goodrick (sgoodrick@lock3software.com) Daveed Vandevoorde
More informationCS152 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 informationCombined Object-Lambda Architectures
www.jquigley.com jquigley#jquigley.com Chicago Lisp April 2008 Research Goals System Goals Conventional Systems Unconventional Systems Research Goals Question: How to make with Pepsi and Coke? The Goal:
More informationBetter Extensibility through Modular Syntax. Robert Grimm New York University
Better Extensibility through Modular Syntax Robert Grimm New York University Syntax Matters More complex syntactic specifications Extensions to existing programming languages Transactions, event-based
More informationSEMANTIC ANALYSIS TYPES AND DECLARATIONS
SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether
More informationTDDE18 & 726G77. Functions
TDDE18 & 726G77 Functions Labs update No more one time password. We will note who have demonstrated during the lab and register this in webreg. Use the terminal to send in your lab! Dont use Visual studio
More informationThe results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false
Test 1 Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. Which celebrity has not received an ACM Turing Award? A. Alan Kay B. John McCarthy C. Dennis Ritchie D. Bjarne Stroustrup
More informationThe Set of Natural Code. Mark Isaacson
The Set of Natural Code Mark Isaacson An invitation for questions A Little History, C to C++ void* myccontainer = containermake(); containeraddelt(myccontainer, 5); containerfree(myccontainer); vector
More information