An Extensible Programrning Environment for Modula-3%

Total Page:16

File Type:pdf, Size:1020Kb

An Extensible Programrning Environment for Modula-3% An Extensible Programrning Environment for Modula-3% Mick Jordan’ Abstract 2 Goals This paper describes the design and implementation of The long term objective was to build a practical envi- a practical programming environment for the Modula-3 ronment to support large scale software development in programming language. The environment is organised Modula-3. Initially, the environment would contain only a around an extensible intermediate representation of pro- basic set of well integrated tools such as a compiler, linker grams and makes extensive use of reusable components. and debugger, but would be capable of supporting real The environment is implemented in Modula-3 and exploits projects on a variety of systems. In the longer term ad- some of the novel features of the language. ditional tools such as code browsers, code analysers, and improvements like smart recompilation would be added, building on the basic environment. In this paper, we 1 Introduction are more concerned with how tools are constructed and combined than with the exact details of their functionality The successof a programming language owes much to its or interface to users of the environment. The idea is that, associatedprogramming environment, especially to the set of tools which enable the construction and modification of if the construction of new tools is made easy enough, programs. W5th a new language there is trade-off between new and powerful tools will appear routinely. Important producing an implementation quickly and in providing a sub-goals for the environment were as follows: rich and powerful set of tools. Choosing the first approach typically results in low quality, poorly integrated tools. The second approach can result in an unacceptable delay A Framework for Program Analysis and before the language can be used. This paper describes Wansformation the design and implementation of a toolset for M,odula-3 [G&39], a new programming language that adds threads, There is a large class of tools which engage in program objects, exceptions and garbage collection to Msodula-2 analysis or transformation, for example, browsers, com- mr83]. Our aim was to steer between the two extremes pilers, pretty-printers. These tools require access to an noted above and produce a basic set of tools designed intermediate representation of program source, and sup- around an open, extensible framework, to which new port mechanisms to facilitate the analysis. It is important tools could be added incrementally. not to prejudice the addition of such tools by choosing an overly restrictive framework. *This work was carried out at Olivetti Software Technolog:y Labora- tory, Menlo Park, CA 94025, USA. +Author’s current address: Digital Systems Research Center, 130 Lytton Avc, Palo Alto, CA 9430 1, USA Extensibility Permission to copy without fee all or part of this material is In order to make effective use of the framework, adding a granted provided that the copies are not made or distributed for new tool must be straightforward. Detailed knowledge of direct commercial advantage, the ACM copyright notic’s and the other tools shouIdnot be necessary. New tools should have title of the publication and its date appear, and notice is given equal status with the initial set. Note that the extensibility that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee is aimed at tool developers rather than at users of the and/or specific permission. environment, although the design does not preclude the @ 1990 ACM O-89791-41 8-X/90/001 2-0066...$1.50 latter as a subsequent enhancement. 66 Portability and Availability this paper. The DIANA reference manual [Goo83], which defines an AST for Ada1 POD83], contains an excellent The system must be portable to a wide range of systems analysis of the fundamental issues and has many useful and execute on stock hardware, typically 3 Mip worksta- recommendations for AST designers. Indeed the design tions with 8-16 Mb of main memory. This placed some of the Modula-3 AST (M3AST) was strongly influenced constraints on the system design and on the degree to by DIANA and several techniques and conventions were which we could incorporate external tools. adopted directly. Where M3AST differs from DIANA is in the explicit use of an object-type hierarchy to capture Implernent in Modula-3 commonality and in the separation of the spetication into pieces that correspond to individual tool fragments. The implementation of a programming environment ex- Also the notion of M3AST as the output from a com- tends from low-level (unsafe) programming through to piler front-end is de-emphasised in favour of support for application-level programming. This is precisely the a wider collection of tools. These techniques contribute area to which Modula-3 is targeted and we believe that to the readability and maintainability of the specification Modula-3 offers a better set of facilities for this area than and aid in supporting extensible tool development. To its competitors. Implementing the compiler for a (sys- illustrate the confusion that can arise with the monolithic tems) language in itself is also a good baseline test of an approach consider our previous experience with an AST implementation, and lends credibility to a new language. for Modula-2+. This AST was defined in a single iuter- face as a collection of variant record types. It was rather 3 Design complex, and it was not always clear when a given node or attribute was set, by which phase (or tool) and whether The two key features needed to achieve the goals are: an attribute was temporary or (usefully) persistent. This confusion did not facilitate extensibility, which demands l A well defined and extensible intermediate represen- some form of incremental&y in the specfication. tation of program text. l A system design that encourages the reuse of com- 4.2 AST Structure ponents. The AST is modeled as an attributed tree. Following The foremost requirement of the intermediate representa- the terminology used in DlANA, the tree contains named tion (IR) is that it be information preserving. That is, with nodes that correspond to non-terminals in an abstract the possible exception of lexical details, all information version of the Modula-3 grammar. Members of the right- present in the source text must be represented in the IR. hand side of the production rule for a non-terminal are The second requirement is that the IR be capable of record- denoted by typed attributes of the node. Non-terminals ing additional information, perhaps implicit in the source with alternative productions, for example, Expression, text, that is generated by other tools in the environment. are modeled as classes whose members are the associated In short the IR must be extensible. One such iR that sat- set of nodes. In other systems, for example the Synthesiser isfies these requirements is an attributed Abstract Syntax Generator [Rep89], classes are referred to as phlyu and Tree (AST), which is well established in the literature as the subtree rooted at a node is called a term. Attribute a sound basis for compiler development [Aho86, Bor88, types may be basic types such as INTEGER,user-specified Don84, Goo83, Rep89]. An extensible AST provides an abstract types, such as might be used to denote an identifier excellent integrationmechanism for the toolset. However, name, or a node or class type. The repetitive constructs for extensibility to really work well, new tool developers in grammar productions are represented by an attribute of must be able to compose existing tools in order to generate type sequence. The set of nodes, classes and attributes suitable AST instances for their task. They must also be corresponding to the language syntax form the backbone of provided with a rich set of packages or tool fragments that the extensible AST and comprise the lexical and syntactic can be invoked to simplify their task. views. A new view is created by adding extra attributes to existing nodes and perhaps by defining new node 4 The Modula-3 Abstract Syntax and class types. An example is the semantic view, where attributes to denote identifier bindings are introduced. The Tree views form a hierarchy that initially reflects the traditional sequence of phases in a compiler. An important kind 4.1 Background of view is one which contains nodes and classes that A detailed discussion of the merits of an AST as the inter- represent an embedded language with its own syntax and mediate representation for programs is beyond the scope of ‘Ada is a registered trademark of the U.S. Government 67 semantics, for example a specification language such as Pre-Linker This view supports the pre-linker tool, de- Larch [Gut85]. The ability to share a single formalism scribed in section 5.4, and detines attributes of a more and to establish interconnects between the two ASTs is global nature, for example the depends-on relation very useful. In the basic toolset there are the following for a module, which is used in determinin g Program AST views: initialisation order. Lexical This view is very simple, defining only the basic types needed to denote identifiers, numbers, com- ments etc. These are used as attribute types in the 4.3 Mapping the AST into a Programming syntactic view. Language Syntactic The syntactic view defines the backbone of the AST, which other views decorate with additional The above discussion treats the AST in an abstract manner, attributes. There is a very close relationship between but ultimately this abstraction must be mapped into some the syntactic view and the Modula-3 grammar. programming language. This can be achieved in many ways and involves several classic space/time/flexibility Pragmas The revised language provides a pragma mech- trade-offs.
Recommended publications
  • Language-Level Support for Exploratory Programming of Distributed Virtual Environments
    In Proc ACM UIST ‘96 (Symp. on User Interface Software and Technology), Seattle, WA, November 6–8, 1996, pp. 83–94. Language-Level Support for Exploratory Programming of Distributed Virtual Environments Blair MacIntyre and Steven Feiner Department of Computer Science, Columbia University, New York, NY, 10027 {bm,feiner}@cs.columbia.edu http://www.cs.columbia.edu/~{bm,feiner} Abstract resulted in an unmanageable welter of client-server relation- ships, with each of a dozen or more processes needing to We describe COTERIE, a toolkit that provides language- create and maintain explicit connections to each other and to level support for building distributed virtual environments. handle inevitable crashes. COTERIE is based on the distributed data-object paradigm for distributed shared memory. Any data object in COTE- We spent a sufficiently large portion of our time reengineer- RIE can be declared to be a Shared Object that is replicated ing client-server code that it became clear to us that our fully in any process that is interested in it. These Shared implementation of the client-server model was unsuitable Objects support asynchronous data propagation with atomic for exploratory programming of distributed research proto- serializable updates, and asynchronous notification of types. The heart of the problem, as we saw it, was a lack of updates. COTERIE is built in Modula-3 and uses existing support for data sharing that was both efficient and easy for Modula-3 packages that support an integrated interpreted programmers to use in the face of frequent and unantici- language, multithreading, and 3D animation. Unlike other pated changes.
    [Show full text]
  • A Trusted Mechanised Javascript Specification
    A Trusted Mechanised JavaScript Specification Martin Bodin Arthur Charguéraud Daniele Filaretti Inria & ENS Lyon Inria & LRI, Université Paris Sud, CNRS Imperial College London [email protected] [email protected] d.fi[email protected] Philippa Gardner Sergio Maffeis Daiva Naudžiunien¯ e˙ Imperial College London Imperial College London Imperial College London [email protected] sergio.maff[email protected] [email protected] Alan Schmitt Gareth Smith Inria Imperial College London [email protected] [email protected] Abstract sation was crucial. Client code that works on some of the main JavaScript is the most widely used web language for client-side ap- browsers, and not others, is not useful. The first official standard plications. Whilst the development of JavaScript was initially just appeared in 1997. Now we have ECMAScript 3 (ES3, 1999) and led by implementation, there is now increasing momentum behind ECMAScript 5 (ES5, 2009), supported by all browsers. There is the ECMA standardisation process. The time is ripe for a formal, increasing momentum behind the ECMA standardisation process, mechanised specification of JavaScript, to clarify ambiguities in the with plans for ES6 and 7 well under way. ECMA standards, to serve as a trusted reference for high-level lan- JavaScript is the only language supported natively by all major guage compilation and JavaScript implementations, and to provide web browsers. Programs written for the browser are either writ- a platform for high-assurance proofs of language properties. ten directly in JavaScript, or in other languages which compile to We present JSCert, a formalisation of the current ECMA stan- JavaScript.
    [Show full text]
  • BCL: a Cross-Platform Distributed Data Structures Library
    BCL: A Cross-Platform Distributed Data Structures Library Benjamin Brock, Aydın Buluç, Katherine Yelick University of California, Berkeley Lawrence Berkeley National Laboratory {brock,abuluc,yelick}@cs.berkeley.edu ABSTRACT high-performance computing, including several using the Parti- One-sided communication is a useful paradigm for irregular paral- tioned Global Address Space (PGAS) model: Titanium, UPC, Coarray lel applications, but most one-sided programming environments, Fortran, X10, and Chapel [9, 11, 12, 25, 29, 30]. These languages are including MPI’s one-sided interface and PGAS programming lan- especially well-suited to problems that require asynchronous one- guages, lack application-level libraries to support these applica- sided communication, or communication that takes place without tions. We present the Berkeley Container Library, a set of generic, a matching receive operation or outside of a global collective. How- cross-platform, high-performance data structures for irregular ap- ever, PGAS languages lack the kind of high level libraries that exist plications, including queues, hash tables, Bloom filters and more. in other popular programming environments. For example, high- BCL is written in C++ using an internal DSL called the BCL Core performance scientific simulations written in MPI can leverage a that provides one-sided communication primitives such as remote broad set of numerical libraries for dense or sparse matrices, or get and remote put operations. The BCL Core has backends for for structured, unstructured, or adaptive meshes. PGAS languages MPI, OpenSHMEM, GASNet-EX, and UPC++, allowing BCL data can sometimes use those numerical libraries, but are missing the structures to be used natively in programs written using any of data structures that are important in some of the most irregular these programming environments.
    [Show full text]
  • The Zonnon Project: a .NET Language and Compiler Experiment
    The Zonnon Project: A .NET Language and Compiler Experiment Jürg Gutknecht Vladimir Romanov Eugene Zueff Swiss Fed Inst of Technology Moscow State University Swiss Fed Inst of Technology (ETH) Computer Science Department (ETH) Zürich, Switzerland Moscow, Russia Zürich, Switzerland [email protected] [email protected] [email protected] ABSTRACT Zonnon is a new programming language that combines the style and the virtues of the Pascal family with a number of novel programming concepts and constructs. It covers a wide range of programming models from algorithms and data structures to interoperating active objects in a distributed system. In contrast to popular object-oriented languages, Zonnon propagates a symmetric compositional inheritance model. In this paper, we first give a brief overview of the language and then focus on the implementation of the compiler and builder on top of .NET, with a particular emphasis on the use of the MS Common Compiler Infrastructure (CCI). The Zonnon compiler is an interesting showcase for the .NET interoperability platform because it implements a non-trivial but still “natural” mapping from the language’s intrinsic object model to the underlying CLR. Keywords Oberon, Zonnon, Compiler, Common Compiler Infrastructure (CCI), Integration. 1. INTRODUCTION: THE BRIEF CCI and b) to experiment with evolutionary language HISTORY OF THE PROJECT concepts. The notion of active object was taken from the Active Oberon language [Gut01]. In addition, two This is a technical paper presenting and describing new concurrency mechanisms have been added: an the current state of the Zonnon project. Zonnon is an accompanying communication mechanism based on evolution of the Pascal, Modula, Oberon language syntax-oriented protocols , borrowed from the Active line [Wir88].
    [Show full text]
  • MODULA a Language for Modular Multiprogramming, Wirth, 1976
    Research Collection Report MODULA a language for modular multiprogramming Author(s): Wirth, Niklaus Publication Date: 1976 Permanent Link: https://doi.org/10.3929/ethz-a-000199440 Rights / License: In Copyright - Non-Commercial Use Permitted This page was generated automatically upon download from the ETH Zurich Research Collection. For more information please consult the Terms of use. ETH Library ~ idgenöss · ische ·Institut T echnisc ~he für. Hochschule Informatik Zürich MODULA: A language formodular multiprogramming ~~8rz 1976 18 ~ ., ' , „· Eidgenössische Institut Technische für Hochschule Informatik Zürich Niklaus Wirth MODULA: A language formodular multiprogramming - 1 - N .Wirth Abstract This paper defines a language called Modula, which is intended primarily for programming dedicated computer systems, including process control systems on smaller machines. The language is largely based on Pascal, but in addition to conventional block ) structure it introduces a so - called module structure . A module is a set of procedures, data types, and variables, where the programmer has precise control over the names that are imported from and exported to the environment. Modula includes general multiprocessing facilities, namely processes , interfacp, modules, and Signals . It also allows the specification of facilities that represent a computer ' s specific peripheral devices . Those given in this paper pertain to the PDP - 11. Author ' s address: Institut für Informatik , ETH , CH-8092 Zürich - 2 - Coaten ts 1. Introduction 3 2. 0 verview 5 3. Notation for syotactic description 10 4. Language vocabulary and representation 10 5. Facilities for sequential programmiog 12 1. Constant declarations 12 2. Type declarations 12 1 • Basic types 13 2. E n um e ratio n s 13 3.
    [Show full text]
  • Automated Fortran–C++ Bindings for Large-Scale Scientific Applications
    Automated Fortran–C++ Bindings for Large-Scale Scientific Applications Seth R Johnson HPC Methods for Nuclear Applications Group Nuclear Energy and Fuel Cycle Division Oak Ridge National Laboratory ORNL is managed by UT–Battelle, LLC for the US Department of Energy github.com/swig-fortran Overview • Introduction • Tools • SWIG+Fortran • Strategies • Example libraries 2 Introduction 3 How did I get involved? • SCALE (1969–present): Fortran/C++ • VERA: multiphysics, C++/Fortran • MPACT: hand-wrapped calls to C++ Trilinos 4 Project background • Exascale Computing Project: at inception, many scientific app codes were primarily Fortran • Numerical/scientific libraries are primarily C/C++ • Expose Trilinos solver library to Fortran app developers: ForTrilinos product 5 ECP: more exascale, less Fortran Higher-level { }Fortran ECP application codes over time (credit: Tom Evans) 6 Motivation • C++ library developers: expand user base, more F opportunities for development and follow-on funding • Fortran scientific app developers: use newly exposed algorithms and tools for your code C • Multiphysics project integration: in-memory coupling of C++ physics code to Fortran physics code • Transitioning application teams: bite-size migration from Fortran to C++ C++ 7 Tools 8 Wrapper “report card” • Portability: Does it use standardized interoperability? • Reusability: How much manual duplication needed for new interfaces? • Capability: Does the Fortran interface have parity with the C++? • Maintainability: Do changes to the C++ code automatically update
    [Show full text]
  • Metal C Programming Guide and Reference
    z/OS Version 2 Release 3 Metal C Programming Guide and Reference IBM SC14-7313-30 Note Before using this information and the product it supports, read the information in “Notices” on page 159. This edition applies to Version 2 Release 3 of z/OS (5650-ZOS) and to all subsequent releases and modifications until otherwise indicated in new editions. Last updated: 2019-02-15 © Copyright International Business Machines Corporation 1998, 2017. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents List of Figures...................................................................................................... vii List of Tables........................................................................................................ ix About this document.............................................................................................xi Who should read this document................................................................................................................. xi Where to find more information..................................................................................................................xi z/OS Basic Skills in IBM Knowledge Center.......................................................................................... xi How to read syntax diagrams......................................................................................................................xi How to send your comments to IBM......................................................................xv
    [Show full text]
  • Programming in Java
    Introduction to Programming in Java An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Princeton University ONLINE PREVIEW !"#$%&'(')!"*+,,,- ./01/23,,,0425,67 Publisher Greg Tobin Executive Editor Michael Hirsch Associate Editor Lindsey Triebel Associate Managing Editor Jeffrey Holcomb Senior Designer Joyce Cosentino Wells Digital Assets Manager Marianne Groth Senior Media Producer Bethany Tidd Senior Marketing Manager Michelle Brown Marketing Assistant Sarah Milmore Senior Author Support/ Technology Specialist Joe Vetere Senior Manufacturing Buyer Carol Melville Copyeditor Genevieve d’Entremont Composition and Illustrations Robert Sedgewick and Kevin Wayne Cover Image: © Robert Sedgewick and Kevin Wayne Page 353 © 2006 C. Herscovici, Brussels / Artists Rights Society (ARS), New York Banque d’ Images, ADAGP / Art Resource, NY Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trade- marks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed in initial caps or all caps. The interior of this book was composed in Adobe InDesign. Library of Congress Cataloging-in-Publication Data Sedgewick, Robert, 1946- Introduction to programming in Java : an interdisciplinary approach / by Robert Sedgewick and Kevin Wayne. p. cm. Includes index. ISBN 978-0-321-49805-2 (alk. paper) 1. Java (Computer program language) 2. Computer programming. I. Wayne, Kevin Daniel, 1971- II. Title. QA76.73.J38S413 2007 005.13’3--dc22 2007020235 Copyright © 2008 Pearson Education, Inc. 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, photocopying, recording, or otherwise, without the prior written permission of the publisher.
    [Show full text]
  • Draft ANSI Smalltalk Standard
    NCITS J20 DRAFT December, 1997 of ANSI Smalltalk Standard revision 1.9 Draft American National Standard for Information Systems - Programming Languages - Smalltalk Notice This is a draft proposed American National Standard. As such, this is not a completed standard. The Technical Committee may modify this document as a result of comments received during public review and its approval as a standard. Permission is granted to members of NCITS, its technical committees, and their associated task groups to reproduce this document for the purposes of NCITS standardization activities without further permission, provided this notice is included. All other rights are reserved. Any commercial or for-profit reproduction is strictly prohibited. NCITS J20 DRAFT December, 1997 ii of ANSI Smalltalk Standard revision 1.9 Copyright Copyright 1997 National Committee for Information Technology Standards Permission is granted to duplicate this document for the purpose of reviewing the draft standard. NCITS J20 DRAFT December, 1997 iii of ANSI Smalltalk Standard revision 1.9 Table of Contents Page FORWARD vi 1. GOALS AND SCOPE .................................................................................................................... 5 2. CONFORMING IMPLEMENTATIONS AND PROGRAMS .................................................. 7 3. THE SMALLTALK LANGUAGE ............................................................................................... 8 3.1 COMPUTATIONAL MODEL OF SMALLTALK EXECUTION................................................................
    [Show full text]
  • Extensibility in the Oberon System
    Nordic Journal of Computing 1(1994), 77{93. EXTENSIBILITY IN THE OBERON SYSTEM HANSPETER MOSSENB¨ OCK¨ ∗ Institute for Computer Systems ETH Zurich¨ CH{8092 Zurich¨ Switzerland Abstract. We show how an object-oriented system-and in particular the Oberon System-can be used to write software that is extensible by end users even while the software is running. Extensibility instead of completeness may be a way out of the unpleasant situation in software industry where applications still tend to become bigger every year. Oberon is both an object-oriented programming language and an operating system with new concepts such as commands and dynamic loading. The language and the system make up an environment that is similar to Smalltalk in its flexibility but offers static type-checking and is much more efficient. CR Classification: D.2.2, D.1.5 1. Introduction Ambitious software systems with large functionality and thousands of users can hardly be designed in a form that meets all future needs from the be- ginning. It is impossible to foresee all the ways in which such systems will be used so that requests for extensions will arise naturally. Current software industry tries to cope with this problem by including as many features as possible into a software system. This leads to huge monolithic software that offers amazing functionality but still leaves some users disappointed because it typically lacks just their favorite feature. The opposite approach is to design a system only as a minimal kernel and to provide means to extend it. This allows vendors and even users to add more functionality later without bothering other users which do not need it.
    [Show full text]
  • Warum Unix-Ports Pascal Bis Oberon in Der Bremer Informatik
    Warum Unix-Ports Pascal bis Oberon in der Bremer Informatik Günter Feldmann Universität Bremen [email protected] 1970th, Dept. of Electrical Engineering ● 1974/75: first university computer CII-Honeywell Bull, IRIS-80 ● first Pascal port from a university in Paris. ● learned Pascal by reading the compiler sources ● engineers needed 64-bit REALS, compiler got modified accordingly ● compiling and linking the compiler took 2 days ● N. Wirth: Systematisches Programmieren Since 1981, Dept. of Mathematics and Computer Science ● first personal computers: DEC PDT 11 ● PDP11 instruction set, but some instructions were missing, these had to be emulated in software as the interpreters and compilers used them. ● UCSD Pascal and some times a Modula (not Modula-2) compiler under RT11. ● Small local area network via V24 connections Computer Science ● A series of different computers ● DEC PDP11/44, BSD Unix ● DEC VAX 750 with 8 VT100 terminals, BSD Unix ● 30 Atari 520 ST (M6800) ● 20 Sun3 Workstations (M6820) ● all machines were equipped with Pascal and/or Modula-2 compilers ● Some machines (Pascal Microengine, PERQ) were microprogrammed for Pascal (p-code, Q- code) Computer Science ● workstation pool for students ● 30 machines (1986), 100 machines today ● in the beginning of 1990th we acquired Sun4 workstations (SPARC). No Modula-2 compiler! ● ETHZ released the SPARC Oberon system hosted by SunOS. This system was used in the course “Software Projekt” until 1996. Then “Java” came … ● programming courses got replaced by courses in “internet programming” Keeping Oberon alive on our hardware ● OS change: SunOS (BSD) to Solaris (SYSVR4) ● despite binary compatibility SPARC Oberon failed. Oberon compiler used registers reserved for usage by the system.
    [Show full text]
  • Functions in C
    Functions in C Fortran 90 has three kinds of units: a program unit, subroutine units and function units. In C, all units are functions. For example, the C counterpart to the Fortran 90 program unit is the function named main: #include <stdio.h> main () /* main */ f float w, x, y, z; int i, j, k; w = 0.5; x = 5.0; y = 10.0; z = x + y * w; i = j = k = 5; printf("x = %f, y = %f, z = %f n", x, y, z); printf("i = %d, j = %d, k = %dnn", i, j, k); /* main */ n g Every C program must have a function named main; it’s the func- tion where the program begins execution. C also has a bunch of standard library functions, which are functions that come predefined for everyone to use. 1 Standard Library Functions in C1 C has a bunch of standard library functions that everyone gets to use for free. They are analogous to Fortran 90’s intrinsic functions, but they’re not quite the same. Why? Because Fortran 90’s intrinsic functions are built directly into the language, while C’s library functions are not really built into the language as such; you could replace them with your own if you wanted. Here’s some example standard library functions in C: Function Return Type Return Value #include file printf int number of characters written stdio.h Print (output) to standard output (the terminal) in the given format scanf int number of items input stdio.h Scan (input) from standard input (the keyboard) in the given format isalpha int Boolean: is argument a letter? ctype.h isdigit int Boolean: is argument a digit? ctype.h strcpy char [ ] string containing copy string.h Copy a string into another (empty) string strcmp int comparison of two strings string.h Lexical comparison of two strings; result is index in which strings differ: negative value if first string less than second, positive if vice versa, zero if equal sqrt float square root of argument math.h pow float 1st argument raised to 2nd argument math.h 1 Brian W.
    [Show full text]