Writing R Extensions

Total Page:16

File Type:pdf, Size:1020Kb

Writing R Extensions Writing R Extensions Version 3.1.3 RC (2015-03-04) R Core Team This manual is for R, version 3.1.3 RC (2015-03-04). Copyright c 1999{2015 R Core Team Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into an- other language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the R Core Team. i Table of Contents Acknowledgements :::::::::::::::::::::::::::::::::::::::::::::::: 1 1 Creating R packages::::::::::::::::::::::::::::::::::::::::::: 2 1.1 Package structure ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 3 1.1.1 The DESCRIPTION file ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 1.1.2 Licensing ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 7 1.1.3 Package Dependencies :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 9 1.1.3.1 Suggested packages ::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 1.1.4 The INDEX file ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 1.1.5 Package subdirectories ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 1.1.6 Data in packages :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 15 1.1.7 Non-R scripts in packages ::::::::::::::::::::::::::::::::::::::::::::::::::: 16 1.2 Configure and cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 16 1.2.1 Using Makevars ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 19 1.2.1.1 OpenMP support ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 22 1.2.1.2 Using pthreads ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 23 1.2.1.3 Compiling in sub-directories :::::::::::::::::::::::::::::::::::::::::::: 24 1.2.2 Configure example::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 24 1.2.3 Using F95 code :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 26 1.2.4 Using C++11 code :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 27 1.3 Checking and building packages :::::::::::::::::::::::::::::::::::::::::::::::::: 28 1.3.1 Checking packages ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 29 1.3.2 Building package tarballs :::::::::::::::::::::::::::::::::::::::::::::::::::: 32 1.3.3 Building binary packages :::::::::::::::::::::::::::::::::::::::::::::::::::: 33 1.4 Writing package vignettes :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 34 1.4.1 Encodings and vignettes ::::::::::::::::::::::::::::::::::::::::::::::::::::: 36 1.4.2 Non-Sweave vignettes:::::::::::::::::::::::::::::::::::::::::::::::::::::::: 37 1.5 Package namespaces :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 37 1.5.1 Specifying imports and exports :::::::::::::::::::::::::::::::::::::::::::::: 38 1.5.2 Registering S3 methods :::::::::::::::::::::::::::::::::::::::::::::::::::::: 39 1.5.3 Load hooks :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 39 1.5.4 useDynLib :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 40 1.5.5 An example ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 42 1.5.6 Namespaces with S4 classes and methods :::::::::::::::::::::::::::::::::::: 42 1.6 Writing portable packages :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 44 1.6.1 PDF size :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 47 1.6.2 Check timing :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 48 1.6.3 Encoding issues ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 48 1.6.4 Portable C and C++ code ::::::::::::::::::::::::::::::::::::::::::::::::::: 49 1.6.5 Binary distribution :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 50 1.7 Diagnostic messages :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 51 1.8 Internationalization :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 52 1.8.1 C-level messages ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 52 1.8.2 R messages :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 53 1.8.3 Preparing translations ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 53 1.9 CITATION files :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 53 1.10 Package types ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 54 1.10.1 Frontend ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 54 ii 1.11 Services ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 55 2 Writing R documentation files :::::::::::::::::::::::::::::: 56 2.1 Rd format:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 56 2.1.1 Documenting functions :::::::::::::::::::::::::::::::::::::::::::::::::::::: 57 2.1.2 Documenting data sets :::::::::::::::::::::::::::::::::::::::::::::::::::::: 61 2.1.3 Documenting S4 classes and methods :::::::::::::::::::::::::::::::::::::::: 62 2.1.4 Documenting packages::::::::::::::::::::::::::::::::::::::::::::::::::::::: 63 2.2 Sectioning :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 63 2.3 Marking text ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 63 2.4 Lists and tables :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 65 2.5 Cross-references :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 66 2.6 Mathematics ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 67 2.7 Figures::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 67 2.8 Insertions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 68 2.9 Indices ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 68 2.10 Platform-specific documentation ::::::::::::::::::::::::::::::::::::::::::::::::: 69 2.11 Conditional text::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 69 2.12 Dynamic pages :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 69 2.13 User-defined macros ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 70 2.14 Encoding ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 71 2.15 Processing documentation files :::::::::::::::::::::::::::::::::::::::::::::::::: 71 2.16 Editing Rd files ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 72 3 Tidying and profiling R code :::::::::::::::::::::::::::::::: 73 3.1 Tidying R code::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 73 3.2 Profiling R code for speed :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 73 3.3 Profiling R code for memory use :::::::::::::::::::::::::::::::::::::::::::::::::: 75 3.3.1 Memory statistics from Rprof ::::::::::::::::::::::::::::::::::::::::::::::: 75 3.3.2 Tracking memory allocations::::::::::::::::::::::::::::::::::::::::::::::::: 76 3.3.3 Tracing copies of an object :::::::::::::::::::::::::::::::::::::::::::::::::: 76 3.4 Profiling compiled code ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 76 3.4.1 Linux ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 77 3.4.1.1 sprof ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 77 3.4.1.2 oprofile and operf ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 77 3.4.2 Solaris :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 80 3.4.3 OS X:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 80 4 Debugging :::::::::::::::::::::::::::::::::::::::::::::::::::: 81 4.1 Browsing ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 81 4.2 Debugging R code :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 82 4.3 Checking memory access ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 86 4.3.1 Using gctorture:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 86 4.3.2 Using valgrind ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 87 4.3.3 Using the Address Sanitizer:::::::::::::::::::::::::::::::::::::::::::::::::: 88 4.3.3.1 Using the Leak Sanitizer :::::::::::::::::::::::::::::::::::::::::::::::: 89 4.3.4 Using the Undefined Behaviour Sanitizer ::::::::::::::::::::::::::::::::::::: 89 4.3.5 Other analyses with `clang' :::::::::::::::::::::::::::::::::::::::::::::::::: 91 4.3.6 Using `Dr. Memory' ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 91 4.3.7 Fortran array bounds checking ::::::::::::::::::::::::::::::::::::::::::::::: 91 4.4 Debugging compiled code::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 91 4.4.1 Finding entry points in dynamically loaded code ::::::::::::::::::::::::::::: 93 4.4.2 Inspecting R objects when debugging :::::::::::::::::::::::::::::::::::::::: 93 iii 5 System and foreign language interfaces::::::::::::::::::::: 96 5.1 Operating system access :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 96 5.2 Interface functions .C and .Fortran :::::::::::::::::::::::::::::::::::::::::::::: 96 5.3 dyn.load and dyn.unload ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 98 5.4 Registering native routines
Recommended publications
  • GNU M4, Version 1.4.7 a Powerful Macro Processor Edition 1.4.7, 23 September 2006
    GNU M4, version 1.4.7 A powerful macro processor Edition 1.4.7, 23 September 2006 by Ren´eSeindal This manual is for GNU M4 (version 1.4.7, 23 September 2006), a package containing an implementation of the m4 macro language. Copyright c 1989, 1990, 1991, 1992, 1993, 1994, 2004, 2005, 2006 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.” i Table of Contents 1 Introduction and preliminaries ................ 3 1.1 Introduction to m4 ............................................. 3 1.2 Historical references ............................................ 3 1.3 Invoking m4 .................................................... 4 1.4 Problems and bugs ............................................. 8 1.5 Using this manual .............................................. 8 2 Lexical and syntactic conventions ............ 11 2.1 Macro names ................................................. 11 2.2 Quoting input to m4........................................... 11 2.3 Comments in m4 input ........................................ 11 2.4 Other kinds of input tokens ................................... 12 2.5 How m4 copies input to output ................................ 12 3 How to invoke macros........................
    [Show full text]
  • UNIX Reference Card
    UNlxt Reference Card distributed by Computing Information Service BELL LABORATORIES Murray Hill, N. J. 07974 compiled by Lorinda Cherry Second Edition March, 1979 TABLE OF CO~TEJIo"TS la. GENERAL UNIX COMMANDS adb general purpose debugger ...S. 21 ar archive & library maimainer. ..S as assembler. ..S at execute commands at designated time S awk pattern scanning & processing language S bas basic ...S basename strip filename affixes ...5 be arbitrary precision interactive language ... S calendar reminder service ... 5 cat concatenate & print...5 cb C program beautifier ...no arguments cc C compiler ...5 cd change working directory 5 chgrp change groupoid of files 6 . chmod change mode of files S chown change owner of files 6 cmp compare 2 files ...6 col filter reverse line feeds ...6 comm print" lines common to 2 files ...6 cp copy ...6 crypt encode/decode 6 date print or set date 6 de desk calculator 6 dd convert & copy a file ...6 deroff remove text formatting commands ...6 diff differential file comparator. ..6 dUO 3-way differential file comparison ...6 du summarize disk usage ...6 echo echo arguments ...7 ed text editor. ..7, 20 egrep full regular expression pattern search ...8 enroll enroll in secret mail...no arguments eqn typeset mathematics ...7. 29 expr evaluate arguments as expressions ...7 fT7 Fortran 77 compiler ... 7 factor factor a number ...7 false truth value ...no arguments fgrep search for a fixed pauern ...8 file determine file type ...7 find find files ...7 graph draw a graph ...7 grep search a file for a pattern ...8 join relational database operator.
    [Show full text]
  • GNU M4, Version 1.4.19 a Powerful Macro Processor Edition 1.4.19, 28 May 2021
    GNU M4, version 1.4.19 A powerful macro processor Edition 1.4.19, 28 May 2021 by Ren´eSeindal, Fran¸coisPinard, Gary V. Vaughan, and Eric Blake ([email protected]) This manual (28 May 2021) is for GNU M4 (version 1.4.19), a package containing an implementation of the m4 macro language. Copyright c 1989{1994, 2004{2014, 2016{2017, 2020{2021 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled \GNU Free Documentation License." i Table of Contents 1 Introduction and preliminaries ::::::::::::::::: 3 1.1 Introduction to m4 :::::::::::::::::::::::::::::::::::::::::::::: 3 1.2 Historical references :::::::::::::::::::::::::::::::::::::::::::: 3 1.3 Problems and bugs ::::::::::::::::::::::::::::::::::::::::::::: 4 1.4 Using this manual :::::::::::::::::::::::::::::::::::::::::::::: 5 2 Invoking m4::::::::::::::::::::::::::::::::::::::: 7 2.1 Command line options for operation modes ::::::::::::::::::::: 7 2.2 Command line options for preprocessor features ::::::::::::::::: 8 2.3 Command line options for limits control ::::::::::::::::::::::: 10 2.4 Command line options for frozen state ::::::::::::::::::::::::: 11 2.5 Command line options for debugging :::::::::::::::::::::::::: 11 2.6 Specifying input files on the command line :::::::::::::::::::::
    [Show full text]
  • Programmer's Manual. the Documents Here Are Grouped
    Programmer’s Manual. The documents here are grouped roughly into the areas of basics, editing, language tools, document preparation, and system maintenance. Further general information may be found in the Bell System Tech- nical Journal special issue on UNIX, July-August, 1978. Many of the documents cited within this volume as Bell Laboratories internal memoranda or Computing Science Technical Reports (CSTR) are also contained here. These documents contain occasional localisms, typically references to other operating systems like GCOS and IBM. In all cases, such references may be safely ignored by UNIX users. General Works 1.7th Edition UNIX — Summary. A concise summary of the facilities available on UNIX. 2.The UNIX Time-Sharing System. D. M. Ritchie and K. Thompson. The original UNIX paper, reprinted from CACM. Getting Started 3.UNIX for Beginners — Second Edition. B. W. Kernighan. An introduction to the most basic use of the system. 4.A Tutorial Introduction to the UNIX Text Editor. B. W. Kernighan. An easy way to get started with the editor. 5.Advanced Editing on UNIX. B. W. Kernighan. The next step. 6.An Introduction to the UNIX Shell. S. R. Bourne. An introduction to the capabilities of the command interpreter, the shell. 7.Learn — Computer Aided Instruction on UNIX. M. E. Lesk and B. W. Kernighan. Describes a computer-aided instruction program that walks new users through the basics of files, the edi- tor, and document preparation software. Document Preparation 8.Typing Documents on the UNIX System. M. E. Lesk. Describes the basic use of the formatting tools. Also describes ‘‘−ms’’, a standardized package of format- ting requests that can be used to lay out most documents (including those in this volume).
    [Show full text]
  • Time-Sharing System
    UNIXTM TIME-SHARING SYSTEM: UNIX PROGRAMMER'S MANUAL Seventh Edition, Volume 2B January, 1979 Bell Telephone Laboratories, Incorporated Murray Hill, New Jersey Yacc: Yet Another Compiler-Compiler Stephen C. Johnson Bell Laboratories Murray Hill, New Jersey 07974 ABSTRACT Computer program input generally has some structure; in fact, every computer program that does input can be thought of as de®ning an ``input language'' which it accepts. An input language may be as complex as a programming language, or as sim- ple as a sequence of numbers. Unfortunately, usual input facilities are limited, dif®cult to use, and often are lax about checking their inputs for validity. Yacc provides a general tool for describing the input to a computer program. The Yacc user speci®es the structures of his input, together with code to be invoked as each such structure is recognized. Yacc turns such a speci®cation into a subroutine that handles the input process; frequently, it is convenient and appropriate to have most of the ¯ow of control in the user's application handled by this subroutine. The input subroutine produced by Yacc calls a user-supplied routine to return the next basic input item. Thus, the user can specify his input in terms of individual input characters, or in terms of higher level constructs such as names and numbers. The user-supplied routine may also handle idiomatic features such as comment and con- tinuation conventions, which typically defy easy grammatical speci®cation. Yacc is written in portable C. The class of speci®cations accepted is a very gen- eral one: LALR(1) grammars with disambiguating rules.
    [Show full text]
  • Oral History of Brian Kernighan
    Oral History of Brian Kernighan Interviewed by: John R. Mashey Recorded April 24, 2017 Princeton, NJ CHM Reference number: X8185.2017 © 2017 Computer History Museum Oral History of Brian Kernighan Mashey: Well, hello, Brian. It’s great to see you again. Been a long time. So we’re here at Princeton, with Brian Kernighan, and we want to go do a whole oral history with him. So why don’t we start at the beginning. As I recall, you’re Canadian. Kernighan: That is right. I was born in Toronto long ago, and spent my early years in the city of Toronto. Moved west to a small town, what was then a small town, when I was in the middle of high school, and then went to the University of Toronto for my undergraduate degree, and then came here to Princeton for graduate school. Mashey: And what was your undergraduate work in? Kernighan: It was in one of these catch-all courses called Engineering Physics. It was for people who were kind of interested in engineering and math and science and didn’t have a clue what they wanted to actually do. Mashey: <laughs> So how did you come to be down here? Kernighan: I think it was kind of an accident. It was relatively unusual for people from Canada to wind up in the United States for graduate school at that point, but I thought I would try something different and so I applied to six or seven different schools in the United States, got accepted at some of them, and then it was a question of balancing things like, “Well, they promised that they would get you out in a certain number of years and they promised that they would give you money,” but the question is whether, either that was true or not and I don’t know.
    [Show full text]
  • Lab Manual of Compiler Design
    LAB MANUAL OF COMPILER DESIGN Department of Electronics & Computer Engg. Dronacharya College Of Engineering Khentawas, Gurgaon – 123506 LIST OF EXPERIMENTS S. No. AIM OF EXPERIMENT 1. STUDY OF LEX AND YACC TOOLS. 2 TO CONVERT REGULAR EXPRESSION INTO NFA. 3 WAP TO FIND FIRST IN CFG. 4. WAP TO FIND STRING IS KEYWORD OR NOT. 5. WAP TO FIND STRING IS IDENTIFIER OR NOT. 6. WAP TO FIND STRING IS CONSTANT OR NOT. 7. WAP TO COUNT NO. OF WHITESPACES AND NEWLINE. 8. WAP TO GENERATE TOKENS FOR THE GIVEN GRAMMER. 9. AN ALGO TO CONVERT NFA TO DFA. 10. AN ALGO FOR MINIMIZING OF DFA. 11. WAP TO CHECK STRING IS IN GRAMMER OR NOT. 12. WAP TO CALCULATE LEADING FOR ALL NON TERMINALS . 13. WAP TO CALCULATE TRAILING FOR ALL NON TERMINALS . PROGRAM NO:-1 PRACTICE OF LEX/YACC OF COMPILER WRITING A compiler or interpreter for a programming language is often decomposed into two parts: 1. Read the source program and discover its structure. 2. Process this structure, e.g. to generate the target program. Lex and Yacc can generate program fragments that solve the first task. The task of discovering the source structure again is decomposed into subtasks: 1. Split the source file into tokens (Lex). 2. Find the hierarchical structure of the program (Yacc). Lex - A Lexical Analyzer Generator Lex is a program generator designed for lexical processing of character input streams. It accepts a high-level, problem oriented specification for character string matching, and produces a program in a general purpose language which recognizes regular expressions.
    [Show full text]
  • Using the GNU Compiler Collection
    Using the GNU Compiler Collection Richard M. Stallman Last updated 20 April 2002 for GCC 3.2.3 Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. For GCC Version 3.2.3 Published by the Free Software Foundation 59 Temple Place—Suite 330 Boston, MA 02111-1307, USA Last printed April, 1998. Printed copies are available for $50 each. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License”, the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”. (a) The FSF’s Front-Cover Text is: A GNU Manual (b) The FSF’s Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ...................................... 1 1 Compile C, C++, Objective-C, Ada, Fortran, or Java ....... 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .......................... 7 4 C Implementation-defined behavior ................. 153 5 Extensions to the C Language Family ................ 157 6 Extensions to the C++ Language ................... 255 7 GNU Objective-C runtime features.................. 267 8 Binary Compatibility ........................... 273 9 gcov—a Test Coverage Program ................... 277 10 Known Causes of Trouble with GCC ...............
    [Show full text]
  • Yacc: Yet Another Compiler-Compiler
    Yacc: Yet Another Compiler-Compiler http://dinosaur.compilertools.net/yacc/index.html The Lex & Yacc Page Yacc: Yet Another Compiler-Compiler Stephen C. Johnson AT&T Bell Laboratories Murray Hill, New Jersey 07974 ABSTRACT Computer program input generally has some structure; in fact, every computer program that does input can be thought of as defining an ``input language'' which it accepts. An input language may be as complex as a programming language, or as simple as a sequence of numbers. Unfortunately, usual input facilities are limited, difficult to use, and often are lax about checking their inputs for validity. Yacc provides a general tool for describing the input to a computer program. The Yacc user specifies the structures of his input, together with code to be invoked as each such structure is recognized. Yacc turns such a specification into a subroutine that handles the input process; frequently, it is convenient and appropriate to have most of the flow of control in the user's application handled by this subroutine. The input subroutine produced by Yacc calls a user-supplied routine to return the next basic input item. Thus, the user can specify his input in terms of individual input characters, or in terms of higher level constructs such as names and numbers. The user-supplied routine may also handle idiomatic features such as comment and continuation conventions, which typically defy easy grammatical specification. Yacc is written in portable C. The class of specifications accepted is a very general one: LALR(1) grammars with disambiguating rules. In addition to compilers for C, APL, Pascal, RATFOR, etc., Yacc has also been used for less conventional languages, including a phototypesetter language, several desk calculator languages, a document retrieval system, and a Fortran debugging system.
    [Show full text]
  • Comparative Programming Languages CM20253
    We have briefly covered many aspects of language design And there are many more factors we could talk about in making choices of language The End There are many languages out there, both general purpose and specialist And there are many more factors we could talk about in making choices of language The End There are many languages out there, both general purpose and specialist We have briefly covered many aspects of language design The End There are many languages out there, both general purpose and specialist We have briefly covered many aspects of language design And there are many more factors we could talk about in making choices of language Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important For example, can you easily join together code written in Java and C? The End Or languages And then the interopability of languages becomes important For example, can you easily join together code written in Java and C? The End Or languages Often a single project can use several languages, each suited to its part of the project For example, can you easily join together code written in Java and C? The End Or languages Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important The End Or languages Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important For example, can you easily
    [Show full text]
  • Macro Memories, 1964–2013
    Macro Memories, 1964{2013 David Walden draft of January 26, 2014 In the summer of 2013, I was looking at a 1973 listing of the ARPANET IMP (Interface Message Processor) program1 which makes extensive use of macros. This caused me to muse about the various macro processors I have used over the past 50 years which, in turn, led to this note. This note is not a thorough study, an extensive tutorial, or a comprehensive bibliography about macro processors. Such descriptions have already been provided by, for instance, Peter Brown, Martin Campbell-Kelly, John Metzner, and Peter Wegner in their longer presentations of the topic.2,3,4,5 Instead, the macro technology thread I follow herein is guided by the order in which I used or studied the various macro processors. I hope this is usefully representative of the scope of macro processor technology. I have three reasons for writing this note. (1) I haven't seen much new written about macro processors in recent years (other than what is on the web); thus, it is perhaps time for a new paper on this sometimes under appreciated topic. (2) Computer professionals and computing historians who have come to their fields only in the last decade or two may not know much about macros, and this is a chance to share my fondness for and perspective on macros. The citations in the endnotes also may be a useful starting point for further study of macros, and maybe these notes will rekindle memories for other long-time computing people like me about some of their own experiences.
    [Show full text]
  • Elements of Programming Style
    THE ELEMENTS OF PROGRAMMING STYLE SECOND EDITION Kernighan and Plauger THE ELEMENTS OF PROGRAMMING STYLE Second Edition Brian W. Kernighan Bell laboratories Murray Hill, New Jersey P. J. Plauger Yourdon, Inc. New York, New York McGRAW-HILL BOOK COMPANY New York St. Lou1; San Franc1;co Auckland Bogota Du;seldorf London Madnd Mexico Montreal New Delhi Panama Pan' Sao Paulo Singapore Sydney Tokyo Toronto Library of Congress Cataloging in Publication Data Kernighan, Brian W. The elements of programming style. Bibliography: p. Includes index. I. Electronic digital computers-Programming. I. Plauger, P.J., date joint author. II. Title. QA 76.6.K47 1978 001.6'42 78-3498 ISBN 0-07-034207-5 The Elements of Programming Style Copyright © 1978, 1974 by Bell Telephone Laboratories, Incorporated. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopy­ ing, recording, or otherwise, without the prior written permission of Bell Laboratories. Printed in the United States of America. 12 13 14 15 DODO 8 9 This book was set in Times Roman and Courier 12 by the authors, using a Graphic Sys­ tems phototypesetter driven by a PDP-11/70 running under the UNIX operating system. UNIX is a Trademark of Bell Laboratories. We are deeply indebted to the following authors and publishers for their kind permission to reproduce excerpts from the following copyrighted material: R V Andree, J P Andree, and D D Andree, Computer Programmmg Techniques, A nalys1s, and Mathematics. Copyright © 1973 by R V Andree By permission of Prentice-Hall, Inc F Bates and M L Douglas, Programmmg Language/One with Structured Programming (Thtrd Edmon) Copyright © 1975 by Prentice-Hall, Inc Reprinted by permission C R Bauer and A P Peluso, Basic Fortran IV with Waifor & Wa(/iv.
    [Show full text]