Free Pascal Language Reference Guide

Total Page:16

File Type:pdf, Size:1020Kb

Free Pascal Language Reference Guide Free Pascal : Reference guide. Reference guide for Free Pascal, version 2.4.2 Document version 2.4 November 2010 Michaël Van Canneyt Contents 1 Pascal Tokens 10 1.1 Symbols......................................... 10 1.2 Comments........................................ 11 1.3 Reserved words..................................... 12 1.3.1 Turbo Pascal reserved words.......................... 12 1.3.2 Free Pascal reserved words........................... 13 1.3.3 Object Pascal reserved words......................... 13 1.3.4 Modifiers.................................... 13 1.4 Identifiers........................................ 13 1.5 Hint directives...................................... 14 1.6 Numbers......................................... 15 1.7 Labels.......................................... 16 1.8 Character strings.................................... 17 2 Constants 19 2.1 Ordinary constants................................... 19 2.2 Typed constants..................................... 20 2.3 Resource strings..................................... 20 3 Types 22 3.1 Base types........................................ 22 3.1.1 Ordinal types.................................. 23 Integers..................................... 23 Boolean types.................................. 24 Enumeration types............................... 25 Subrange types................................. 26 3.1.2 Real types.................................... 27 3.2 Character types..................................... 27 3.2.1 Char....................................... 27 3.2.2 Strings..................................... 28 3.2.3 Short strings.................................. 28 1 CONTENTS 3.2.4 Ansistrings................................... 29 3.2.5 UnicodeStrings................................. 31 3.2.6 WideStrings................................... 31 3.2.7 Constant strings................................. 31 3.2.8 PChar - Null terminated strings........................ 32 3.3 Structured Types.................................... 32 Packed structured types............................. 33 3.3.1 Arrays...................................... 34 Static arrays................................... 34 Dynamic arrays................................. 36 Packing and unpacking an array........................ 38 3.3.2 Record types.................................. 38 3.3.3 Set types.................................... 42 3.3.4 File types.................................... 43 3.4 Pointers......................................... 43 3.5 Forward type declarations................................ 45 3.6 Procedural types..................................... 46 3.7 Variant types...................................... 47 3.7.1 Definition.................................... 47 3.7.2 Variants in assignments and expressions.................... 48 3.7.3 Variants and interfaces............................. 49 4 Variables 51 4.1 Definition........................................ 51 4.2 Declaration....................................... 51 4.3 Scope.......................................... 53 4.4 Initialized variables................................... 53 4.5 Thread Variables.................................... 54 4.6 Properties........................................ 54 5 Objects 58 5.1 Declaration....................................... 58 5.2 Fields.......................................... 59 5.3 Static fields....................................... 60 5.4 Constructors and destructors.............................. 61 5.5 Methods......................................... 62 5.5.1 Declaration................................... 62 5.5.2 Method invocation............................... 63 Static methods................................. 63 Virtual methods................................. 64 Abstract methods................................ 65 2 CONTENTS 5.6 Visibility........................................ 66 6 Classes 67 6.1 Class definitions..................................... 67 6.2 Class instantiation.................................... 71 6.3 Methods......................................... 71 6.3.1 Declaration................................... 71 6.3.2 invocation.................................... 71 6.3.3 Virtual methods................................. 72 6.3.4 Class methods................................. 73 6.3.5 Message methods................................ 73 6.3.6 Using inherited................................. 75 6.4 Properties........................................ 76 6.4.1 Definition.................................... 76 6.4.2 Indexed properties............................... 78 6.4.3 Array properties................................ 79 6.4.4 Default properties................................ 80 6.4.5 Storage information.............................. 80 6.4.6 Overriding properties.............................. 81 7 Interfaces 83 7.1 Definition........................................ 83 7.2 Interface identification: A GUID............................ 84 7.3 Interface implementations............................... 85 7.4 Interfaces and COM................................... 86 7.5 CORBA and other Interfaces.............................. 86 7.6 Reference counting................................... 86 8 Generics 88 8.1 Introduction....................................... 88 8.2 Generic class definition................................. 88 8.3 Generic class specialization............................... 90 8.4 A word about scope................................... 91 9 Expressions 94 9.1 Expression syntax.................................... 95 9.2 Function calls...................................... 96 9.3 Set constructors..................................... 98 9.4 Value typecasts..................................... 98 9.5 Variable typecasts.................................... 99 9.6 Unaligned typecasts................................... 100 3 CONTENTS 9.7 The @ operator..................................... 100 9.8 Operators........................................ 101 9.8.1 Arithmetic operators.............................. 101 9.8.2 Logical operators................................ 102 9.8.3 Boolean operators............................... 102 9.8.4 String operators................................. 103 9.8.5 Set operators.................................. 103 9.8.6 Relational operators.............................. 105 9.8.7 Class operators................................. 106 10 Statements 108 10.1 Simple statements.................................... 108 10.1.1 Assignments.................................. 108 10.1.2 Procedure statements.............................. 109 10.1.3 Goto statements................................. 110 10.2 Structured statements.................................. 111 10.2.1 Compound statements............................. 111 10.2.2 The Case statement.............................. 112 10.2.3 The If..then..else statement...................... 113 10.2.4 The For..to/downto..do statement................... 114 10.2.5 The For..in..do statement......................... 115 10.2.6 The Repeat..until statement....................... 122 10.2.7 The While..do statement.......................... 123 10.2.8 The With statement.............................. 124 10.2.9 Exception Statements.............................. 125 10.3 Assembler statements.................................. 125 11 Using functions and procedures 127 11.1 Procedure declaration.................................. 127 11.2 Function declaration.................................. 128 11.3 Function results..................................... 128 11.4 Parameter lists...................................... 129 11.4.1 Value parameters................................ 129 11.4.2 Variable parameters............................... 130 11.4.3 Out parameters................................. 131 11.4.4 Constant parameters.............................. 132 11.4.5 Open array parameters............................. 133 11.4.6 Array of const................................. 133 11.5 Function overloading.................................. 136 11.6 Forward defined functions............................... 136 11.7 External functions.................................... 137 4 CONTENTS 11.8 Assembler functions.................................. 138 11.9 Modifiers........................................ 138 11.9.1 alias....................................... 139 11.9.2 cdecl...................................... 140 11.9.3 export...................................... 141 11.9.4 inline...................................... 141 11.9.5 interrupt..................................... 141 11.9.6 iocheck..................................... 141 11.9.7 local....................................... 142 11.9.8 nostackframe.................................. 142 11.9.9 overload..................................... 142 11.9.10 pascal...................................... 143 11.9.11 public...................................... 143 11.9.12 register..................................... 144 11.9.13 safecall..................................... 144 11.9.14 saveregisters.................................. 144 11.9.15 softfloat..................................... 145 11.9.16 stdcall...................................... 145 11.9.17 varargs..................................... 145 11.10Unsupported Turbo Pascal modifiers.......................... 145 12 Operator overloading 146 12.1 Introduction....................................... 146 12.2 Operator declarations.................................. 146 12.3 Assignment operators.................................
Recommended publications
  • Chapter 5 Names, Bindings, and Scopes
    Chapter 5 Names, Bindings, and Scopes 5.1 Introduction 198 5.2 Names 199 5.3 Variables 200 5.4 The Concept of Binding 203 5.5 Scope 211 5.6 Scope and Lifetime 222 5.7 Referencing Environments 223 5.8 Named Constants 224 Summary • Review Questions • Problem Set • Programming Exercises 227 CMPS401 Class Notes (Chap05) Page 1 / 20 Dr. Kuo-pao Yang Chapter 5 Names, Bindings, and Scopes 5.1 Introduction 198 Imperative languages are abstractions of von Neumann architecture – Memory: stores both instructions and data – Processor: provides operations for modifying the contents of memory Variables are characterized by a collection of properties or attributes – The most important of which is type, a fundamental concept in programming languages – To design a type, must consider scope, lifetime, type checking, initialization, and type compatibility 5.2 Names 199 5.2.1 Design issues The following are the primary design issues for names: – Maximum length? – Are names case sensitive? – Are special words reserved words or keywords? 5.2.2 Name Forms A name is a string of characters used to identify some entity in a program. Length – If too short, they cannot be connotative – Language examples: . FORTRAN I: maximum 6 . COBOL: maximum 30 . C99: no limit but only the first 63 are significant; also, external names are limited to a maximum of 31 . C# and Java: no limit, and all characters are significant . C++: no limit, but implementers often impose a length limitation because they do not want the symbol table in which identifiers are stored during compilation to be too large and also to simplify the maintenance of that table.
    [Show full text]
  • Rapid Application Development Software | Codegear RAD Studio
    RAD Studio 2010 Product Review Guide August 2009 Corporate Headquarters EMEA Headquarters Asia-Pacific Headquarters 100 California Street, 12th Floor York House L7. 313 La Trobe Street San Francisco, California 94111 18 York Road Melbourne VIC 3000 Maidenhead, Berkshire Australia SL6 1SF, United Kingdom RAD Studio 2010 Reviewer Guide TABLE OF CONTENTS Table of Contents ............................................................................................................................ - 1 - Introduction ...................................................................................................................................... - 3 - General Overview of RAD Studio 2010 ...................................................................................... - 3 - What is New in RAD Studio 2010 ............................................................................................... - 3 - A Word on Delphi Prism ............................................................................................................. - 6 - Prerequisites ................................................................................................................................ - 7 - Minimum System Requirements ................................................................................................. - 7 - Internationalizations .................................................................................................................... - 7 - Editions ........................................................................................................................................
    [Show full text]
  • RPC Broker 1.1 Deployment, Installation, Back-Out, and Rollback Ii May 2020 (DIBR) Guide
    RPC Broker 1.1 Deployment, Installation, Back-Out, and Rollback (DIBR) Guide May 2020 Department of Veterans Affairs (VA) Office of Information and Technology (OIT) Enterprise Program Management Office (EPMO) Revision History Documentation Revisions Date Revision Description Authors 05/05/2020 8.0 Tech Edits based on the Broker REDACTED Development Kit (BDK) release with RPC Broker Patch XWB*1.1*71: • Changed all references throughout to “Patch XWB*1.1*71” as the latest BDK release. • Updated the release date in Section 3. • Updated all project dates in Table 4. • Added a “Skip This Step” note in Section 4.3.2. • Updated “Disclaimer” note in Section 4.8. • Added “Skip Step ” disclaimer to Section 4.8.1. • Deleted Sections 4.8.1.3, 4.8.1.3.1, and 4.8.1.3.2, since there are no VistA M Server routines installed with RPC Broker Patch XWB*1.1*71. • Updated Section 4.8.2.1.4; deleted Figure 3, “Sample Patch XWB*1.1*71 Installation Dialogue (Test System),” since there are no VistA M Server routines installed with RPC Broker Patch XWB*1.1*71. • Updated Section 5.2; Added content indicating install is only on Programmer-Only workstations. • Updated Section 5.6.1; added a “Skip Step” disclaimer and deleted Figure 9, “Restoring VistA M Server Files from a Backup Message,” since there are no VistA M Server routines RPC Broker 1.1 Deployment, Installation, Back-Out, and Rollback ii May 2020 (DIBR) Guide Date Revision Description Authors installed with RPC Broker Patch XWB*1.1*71.
    [Show full text]
  • A Concurrent PASCAL Compiler for Minicomputers
    512 Appendix A DIFFERENCES BETWEEN UCSD'S PASCAL AND STANDARD PASCAL The PASCAL language used in this book contains most of the features described by K. Jensen and N. Wirth in PASCAL User Manual and Report, Springer Verlag, 1975. We refer to the PASCAL defined by Jensen and Wirth as "Standard" PASCAL, because of its widespread acceptance even though no international standard for the language has yet been established. The PASCAL used in this book has been implemented at University of California San Diego (UCSD) in a complete software system for use on a variety of small stand-alone microcomputers. This will be referred to as "UCSD PASCAL", which differs from the standard by a small number of omissions, a very small number of alterations, and several extensions. This appendix provides a very brief summary Of these differences. Only the PASCAL constructs used within this book will be mentioned herein. Documents are available from the author's group at UCSD describing UCSD PASCAL in detail. 1. CASE Statements Jensen & Wirth state that if there is no label equal to the value of the case statement selector, then the result of the case statement is undefined. UCSD PASCAL treats this situation by leaving the case statement normally with no action being taken. 2. Comments In UCSD PASCAL, a comment appears between the delimiting symbols "(*" and "*)". If the opening delimiter is followed immediately by a dollar sign, as in "(*$", then the remainder of the comment is treated as a directive to the compiler. The only compiler directive mentioned in this book is (*$G+*), which tells the compiler to allow the use of GOTO statements.
    [Show full text]
  • VERSION 2.0 Referene MANUAL
    VERSION 2.0 REFERENe MANUAL BORlAnD INTERNATIONAL Borland International 4113 Scotts Valley Drive Scotts Valley, California 95066 Copyright Notice© This software package and manual are copyrighted 1983, 1984 by BORLAND INTERNATIONAL Inc. All rights reserved worldwide. No part of this publication may be reproduced, transmitted, transcribed, stored in any retrieval system, or translated into any language by any means without the express written per­ mission of BORLAND INTERNATIONAL Inc., 4113 Scotts Valley Drive, Scotts Valley, CA 95066, USA. Single CPU License The price paid for one copy of TURBO Pascal licenses you to use the product on one CPU when and only when you have signed and returned the License Agreement printed in this book. Disclaimer Borland International makes no warranties as to the contents of this manual and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose. Borland International further reserves the right to make changes to the specifications of the program and contents of the manual without obligation to notify any person or organization of such changes. Fifth edition, October 1984 Printed in the United States of America 98765 TABLE OF CONTENTS INTRODUCTION ............................................. 1 The Pascal Language .........................................1 TURBO Pascal ..............................................1 Structure of This Manual ..................................... 2 Typography ............................................... 3 Syntax Descriptions
    [Show full text]
  • TURBO Pascal Tutor·
    The TURBO Pascal Tutor· A Self-Study Guide to TURBO Pascal Copyright @1984 Copyright @1985 BORLAND INTERNATIONAL, INC. 4585 Scotts Valley Drive Scotts Valley, CA 95066 U.S.A. Borland's No-Nonsense License Statement! This software is protected by both United States Copyright Law and International Treaty provisions. Therefore you must treat this software just like a book with the following single exception. Borland International authorizes you to make archival copies of the software for the sole purpose of backing-up your software and protecting your investment from loss. By saying, "just like a book", Borland means for example that this software may be used by any number of people and may be freely moved from one computer location to another so long as there is No Possibility of it being used at one location while it's being used at another. Just like a book that can't be read by two different people in two different places at the same time, neither can the software be used by two different people in two different places at the same time. (Unless, of course, Borland's Copyright has been violated.) WARRANTY With respect to the physical diskette and physical documentation enclosed herein, BORLAND INTERNATIONAL, INC., ("BORLAND") warrants the same to be free of defects in materials and workmanship for a period of 30 days from the date of purchase. In the event of notification within the warranty period of defects in material or workmanship, BORLAND will replace the defective diskette or documentation. The remedy for breach of this warranty shall be limited to replacement and· shall not encompass any other damages, including but not limited to loss of profit, special, incidental, consequential, or other similar claims.
    [Show full text]
  • LAZARUS FREE PASCAL Développement Rapide
    LAZARUS FREE PASCAL Développement rapide Matthieu GIROUX Programmation Livre de coaching créatif par les solutions ISBN 9791092732214 et 9782953125177 Éditions LIBERLOG Éditeur n° 978-2-9531251 Droits d'auteur RENNES 2009 Dépôt Légal RENNES 2010 Sommaire A) À lire................................................................................................................5 B) LAZARUS FREE PASCAL.............................................................................9 C) Programmer facilement..................................................................................25 D) Le langage PASCAL......................................................................................44 E) Calculs et types complexes.............................................................................60 F) Les boucles.....................................................................................................74 G) Créer ses propres types..................................................................................81 H) Programmation procédurale avancée.............................................................95 I) Gérer les erreurs............................................................................................105 J) Ma première application................................................................................115 K) Bien développer...........................................................................................123 L) L'Objet..........................................................................................................129
    [Show full text]
  • Language Interoperability in Control Network Programming
    International Journal of Science and Engineering Investigations vol. 7, issue 78, July 2018 ISSN: 2251-8843 Language Interoperability in Control Network Programming Kostadin Kratchanov1, Efe Ergün2 1,2Yaşar University, Izmir, Turkey ([email protected], [email protected]) Abstract - Control Network Programming (CNP) is a There is a number of reasons why language interoperability programming paradigm which is being described with the is highly desirable. For example, if a programmer has to maxim “Primitives + Control Network = Control Network implement a specific feature that has been already implemented program”. It is a type of graphic programming. The Control in another language the corresponding program component can Network is a recursive system of graphs; it can be a purely simply be reused. Some languages are especially fit and descriptive specification of the problem being solved. Clearly, effective in implementing specific features and often have ‘drawing’ the control network does not include any emerged to target particular problem domains. Rich third-party programming. The Primitives are elementary, easily packages for certain languages are available. Also, every understandable and clearly specified actions. Ultimately, they programmer usually has a preferred language in which their have to be programmed. Historically, they are usually coded in expertise and efficiency is better. There are hundreds of Free Pascal. The actual code of the primitives has never been programming languages used and constantly being developed considered important. The essence of an “algorithm” is thus making language interoperability a necessity. represented by its control network. CNP was always meant to Programmers with experience and preferences in different be an easy and fast approach for software application programming languages can easier team up for solving development that actually involves very little real complex tasks.
    [Show full text]
  • Concise Introduction to C++
    i i final3 2012/4/19 page 47 i i Chapter 2 Concise Introduction to C++ C++ seems to be most suitable for many practical applications. Indeed, C++ is sufficiently high-level to allow transparent object-oriented programming and efficient use of human resources, yet is also sufficiently low-level to have types, variables, pointers, arrays, and loops to allow efficient use of computer resources. In this chapter, we give a concise description of C++ and illustrate its power as an object-oriented programming language. In particular, we show how to construct and use abstract mathematical objects such as vectors and matrices. We also explain the notion of a template class, which can be filled with a concrete type later on in compilation time. We also discuss inheritance and illustrate its potential. 2.1 Objects As we have seen above, C is a language based on functions. Every command is also a function that returns a value that can be further used or abandoned, according to the wish of the programmer. Furthermore, programmers can write their own functions, which may also return variables of the type specified just before the function name. When the function is called, a temporary, unnamed variable is created to store the returned value until it has been used. C++, on the other hand, is an object-oriented programming language. In this kind of language, the major concern is not the functions that can be executed but rather the objects upon which they operate. Although C++ supports all the operations and features available in C, its point of view is different.
    [Show full text]
  • Type Extensions, Wirth 1988
    Type Extensions N. WIRTH lnstitut fijr Informatik, ETH, Zurich Software systems represent a hierarchy of modules. Client modules contain sets of procedures that extend the capabilities of imported modules. This concept of extension is here applied to data types. Extended types are related to their ancestor in terms of a hierarchy. Variables of an extended type are compatible with variables of the ancestor type. This scheme is expressed by three language constructs only: the declaration of extended record types, the type test, and the type guard. The facility of extended types, which closely resembles the class concept, is defined in rigorous and concise terms, and an efficient implementation is presented. Categories and Subject Descriptors: D.3.3 [Programming Languages]: Language Constructs-data types and structures; modules, packuges; D.3.4 [Programming Languages]: Processors-code generation General Terms: Languages Additional Key Words and Phrases: Extensible data type, Modula-2 1. INTRODUCTION Modern software development tools are designed for the construction of exten- sible systems. Extensibility is the cornerstone for system development, for it allows us to build new systems on the basis of existing ones and to avoid starting each new endeavor from scratch. In fact, programming is extending a given system. The traditional facility that mirrors this concept is the module-also called package-which is a collection of data definitions and procedures that can be linked to other modules by an appropriate linker or loader. Modern large systems consist, without exception, of entire hierarchies of such modules. This notion has been adopted successfully by modern programming languages, such as Mesa [4], Modula-2 [8], and Ada [5], with the crucial property that consistency of interfaces be verified upon compilation of the source text instead of by the linking process.
    [Show full text]
  • Differences Between Oberon and Oberon–2
    Oberon2.Differences.Text (20 Jul 93) 0 Differences between Oberon and Oberon–2 H. Mössenböck, N. Wirth Institut für Computersysteme, ETH Zürich Oberon–2 is a true extension of Oberon [1]. This paper summarizes the extensions and tries to shed some light on the motivations behind them. By that we hope to make it easier for the reader to classify Oberon–2. For details the reader is referred to the language report. One important goal for Oberon–2 was to make object–oriented programming easier without sacrificing the conceptual simplicity of Oberon. After three years of using Oberon and its experimental offspring Object Oberon [2] we merged our experiences into a single refined version of Oberon. The new features of Oberon–2 are type–bound procedures, read–only export of variables and record fields, open arrays as pointer base types, and a with statement with variants. The for statement is reintroduced after having been eliminated in the step from Modula–2 to Oberon. Oberon–2 is the result of many discussions among all members of the Institute for Computer Systems at ETH. It is particularly influenced by the ideas of Jürg Gutknecht and Josef Templ. Type–bound procedures Procedures can be bound to a record (or a pointer) type. They are equivalent to methods in object–oriented terminology. The binding is expressed by a separate parameter (the operand to which the procedure is applicable, or the "receiver" as it is called in object–oriented terminology). TYPE Figure = POINTER TO FigureDesc; FigureDesc = RECORD x, y, w, h: INTEGER END; PROCEDURE (f: Figure) Draw; BEGIN ..
    [Show full text]
  • Concepts in Programming Languages Practicalities
    Concepts in Programming Languages Practicalities I Course web page: Alan Mycroft1 www.cl.cam.ac.uk/teaching/1617/ConceptsPL/ with lecture slides, exercise sheet and reading material. These slides play two roles – both “lecture notes" and “presentation material”; not every slide will be lectured in Computer Laboratory detail. University of Cambridge I There are various code examples (particularly for 2016–2017 (Easter Term) JavaScript and Java applets) on the ‘materials’ tab of the course web page. I One exam question. www.cl.cam.ac.uk/teaching/1617/ConceptsPL/ I The syllabus and course has changed somewhat from that of 2015/16. I would be grateful for comments on any remaining ‘rough edges’, and for views on material which is either over- or under-represented. 1Acknowledgement: various slides are based on Marcelo Fiore’s 2013/14 course. Alan Mycroft Concepts in Programming Languages 1 / 237 Alan Mycroft Concepts in Programming Languages 2 / 237 Main books Context: so many programming languages I J. C. Mitchell. Concepts in programming languages. Cambridge University Press, 2003. Peter J. Landin: “The Next 700 Programming Languages”, I T.W. Pratt and M. V.Zelkowitz. Programming Languages: CACM (published in 1966!). Design and implementation (3RD EDITION). Some programming-language ‘family trees’ (too big for slide): Prentice Hall, 1999. http://www.oreilly.com/go/languageposter http://www.levenez.com/lang/ ? M. L. Scott. Programming language pragmatics http://rigaux.org/language-study/diagram.html (4TH EDITION). http://www.rackspace.com/blog/ Elsevier, 2016. infographic-evolution-of-computer-languages/ I R. Harper. Practical Foundations for Programming Plan of this course: pick out interesting programming-language Languages.
    [Show full text]