Principles of Programming Languages

Total Page:16

File Type:pdf, Size:1020Kb

Principles of Programming Languages Principles of Programming Languages Lecture 02 Criteria for Language Design C SC 520 Principles of Programming Languages ↓ cut ↓ ↓ cut ↓ hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 1 | | + + Criteria for Language Design 1. Simplicity — mnemonic — clear easily mastered semantics — as few basic concepts as possible — feature/concepts limited enough to master entire language (discourages "dialecting") — effects of feature combinations easily predictable — simple rules of combination ex: (1) PL/I: default coercion rules among fixed bin, fixed dec, float bin, float dec, when modified by scale attributes, become very complex. Each rule is reasonable by itself—the combination yields strange results. + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 2 | | + + dcl M fixed dec(10,5), N fixed bin(5,4); N=0; M=N+.1; expr attr. repn. val. .1 dec(1,1) 0.1 (dec) 1/10 N+.1 bin(5,4) 0.0001|100110011 .. 1/16 (binary conversion, then truncation) M dec(10,5) 00000.06250 (dec) 1/16 (2) ALGOL 60: — own static — array dynamic size (known at block entry) ex: own boolean array B[M:N]; — created on first entry to block — retained between entries to block (with values at block exit) — seemingly could vary in size — conflicts with stack implementation — meaning? + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 3 | | + + (3) PASCAL: fairly simple (4) ADA: Entia non sint multiplicanda praeter necessitatem —William of Ockham — procedure calls: keyword or positional for actual/formal correspondence — but positional parameters must occur first, and once a keyword is used, rest of the call must use keyword parms REORDER_KEYS(NUM_OF_ITEMS, KEY_ARRAY :=: RESULT_TABLE); + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 4 | | + + 2. Well-defined Syntactic/Semantic Description g syntax — not a problem to specify once designed g semantics — big problem; still often informal — ALGOL 68 Report (1968) — Revised Report on ALGOL 68 (1975) — Informal Introduction to ALGOL 68, Lindsey & Van der Meulen (1977) g Chapter 0: Very Informal Introduction to ALGOL 68 g Techniques — Interpretive (operational): PL/I (VDL, Wegner, 1972) — Axiomatic: PASCAL (Hoare-Wirth, 1971) — Denotational: Scheme (Steele & Sussman, 1978) + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 5 | | + + ex: (1) ALGOL 60: Lack of complete syntax and semantics (especially I/O) harmed adoption (2) PASCAL: forward left out of grammar; demands definition before use but makes exceptions for recursive types (3) PASCAL: When are types equivalent? The Report is ambiguous type t = array[1..100] of real; var a, b: array[1..100] of real; c:array[1..2] of t; d:array[1..2] of array[1..100] of real; e:t; f:array[1..100] of real; g:t; — structural equivalence: equivalent if have same type structure g {a, b, e, f , g} : array[1..100] of real; g {c, d} : array[1..2] of array[1..100] of real; + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 6 | | + + — declaration equivalence: variables type compatible ⇔ have same type name (built-in or user-defined) or appear in the same declaration (ex: PASCAL) g {a, b} (same declaration) g { f } (distinct declaration) g {e, g} (both of type t) g {c}, {d} (distinct declaration) — name equivalence: variables type compatible ⇔ have same type name (built-in or user-defined) (ex: ADA) g only {e, g} (both of type t) g all others inequivalent (4) DO loops in early FORTRAN: is the index value available after transfer out? + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 7 | | + + (5) ALGOL 60: Semantics of assignments From the Algol 60 Report: ‘‘4.2.3. Semantics [of assignment statement] Assignment statements serve for assigning the value of an expression to one or several variables ... The process will in the general case be understood to take place in three steps as follows: 4.2.3.1. Any subscript expressions occurring in the left part variables are evaluated in sequence from left to right. 4.2.3.2. The expression of the statement is evaluated. 4.2.3.3. The value of the expression is assigned to all the left part variables, with any subscript expressions having values as evaluated in step 4.2.3.1.’’ begin integer a; integer procedure f(x, y); value y,x; integer y,x; a:=f:=x+1; integer procedure g(x); integer x; x:=g:=a+2; a := 0; outreal(1, a + (f(a,g(a)) / g(a)) ) end Many possible evaluations of: a + ( f(a,g(a)) / g(a) ) + + | | a + ( f(a,g(a)) / g(a) ) + a / g(x) by name: x:=g:=a+2 fg f(x,y) by value: a g a a:=f:=x+1 a main: a:=0; print expr C SC 520 Principles of Programming Languages (a) Eval denom. 1st, then numer. L-R 31 g(x) by name: 34+= 22 + x:=g:=a+2 8 f(x,y) by value: f 3 = a=3 g 2 a:=f:=x+1 a / 7 6 main: f:=3 a:=0; a:=3 g:=2 print expr fg1 a:=2 5 g:=4 a:=4 a=2 a=0 2a g 4 a 0 a=2 3a C SC 520 Principles of Programming Languages (b) Eval standard topological sort (L-R) 11 g(x) by name: 0 += 33 + x:=g:=a+2 8 f 1 f(x,y) by value: = a=0 g 3 a:=f:=x+1 a / 0 7 main: f:=1 a:=0; a:=1 g:=3 print expr fg6 a:=3 4 g:=2 a:=2 a=0 a=1 1a g 3 a 5 a=0 2a (c) Other possible results (11 total) 3354 3 1 3 1 1 33537 5223 5 3 5 2 2 C SC 520 Principles of Programming Languages Another Example: • Bad: A[ a + B[f(a)] + g(a) ] := C[a] := 0; • Algol examples from D.E. Knuth, ``The Remaining Trouble Spots in ALGOL 60’’, CACM 1967. C SC 520 Principles of Programming Languages hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 12 | | + + (6) C, C++: Semantics of expressions & assignments a = f(i); a += g(i); a = f(i) + g(i); NOT equivalent. Result of one is known; result of the other is unknown. (7) C++: There are 6 different kinds of scope: — block (local) scope: names declared in a block & formal parameters defined in any enclosed block/function (except if redeclared) — function scope: labels defined throughout function in which declared — function prototype scope: names in the parameter list extend to the end of prototype definition — file (global) scope: name declared outside all blocks/classes is defined throughout the translation unit + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 13 | | + + — class scope: class member name n is local to its class C and can be used only (1) as n in another member function of class C (2) as c.n where c is an object of class C (or a derived class of C) (3) as pc->n where pc is a pointer to an object of class C (or a derived class of C) (4) as X::n (scope resolution operator) where X is C (or a derived class of C) — namespace scope: names defined only inside the namespace (a named collection of classes) or ofoutside using scope resolution operator :: (namespaces support multivendor libraries with potential name conflicts) namespace std { #include <iostream.h> #include <math.h> } namespace SOFTinc { class stack ( ... }; class queue { ... }; } // here use std::<< using namespace std; // here use << for std::<< using namespace SOFTinc; // here use stack for SOFTinc::stack + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 14 | | + + 3. Reliability/Safety — Reliability: syntactic errors not easy to introduce and discouraged (related to readability) — Safety: semantic errors detectable, preferably at compile time ex: (1) ALGOL 60: missing ; after comment absorbs next statement ⇒ strange errors (2) PL/I: FOO: PROC OPTIONS(MAIN); DCL ... ON ENDFILE(SYSIN) BEGIN; . END; (forgot ). DO I=1 BY 1; . (forgot END;) END FOO; Last END creates end for FOO and any other enclosed structures with forgotton ENDs—with no warning! + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 15 | | + + (3) PASCAL: ; is a separator, not a terminator as in PL/I, ADA PASCAL (separator bad): if C then S 1 else S 2 ; S 3 ; {error without begin S 2 ;S3 end ; } ADA (terminator good): if C then S 1 else S 2 ; S 3 ; (* ok *) end if ; g [Ripley & Druseikis, Computer Languages 3 (1978) 227-240] [Gannon, CACM 20 (1977) 584-595] — 20% of all PASCAL syntax errors are ; terminator errors — 7.5% are missing begin , end + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 16 | | + + (4) Use unique delimiters for different constructs ADA: if end if ; for end loop; case end case; ALGOL 68: do od if fi case esac ?!: comment tnemmoc + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 17 | | + + (5) PASCAL variant records: type compatibility cannot be checked at compile time type scale = (large, huge) ; measurement = record unit : string ; case size : scale of large : (exact : integer) ; huge : (approx : real) end ; var dist : measurement ; _______ unit→ |_______| size→ |_______|(tag field) exact, approx→ |_______| (∗) dist.exact is meaningful ⇔ dist.size = large dist.approx is meaningful ⇔ dist.size = huge — Programmer can alter dist.size — Cannot enforce (∗) at compile time — To enforce at runtime every reference to a variant field must check the tag field value (large or huge). Never done in practice. + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 18 | | + + (6) C, C++: == vs. = if (n = 0) exception(); else norm(); (7) C, C++: Implicit pointer conversions char* mem; void* gen_ptr; gen_ptr = mem; // C and C++ mem = gen_ptr; // assignt. compatible in C // illegal in C++ (8) Comments in C++ // FILE: rat.h // ... class Rat { public: // CONSTRUCTORS Rat(int n = 0, int d = 1); // default constructor: Rat r // Rat(5) ==> 5/1 Rat(const Rat& r); // copy constructor Rat(double d); // init by a double value // DESTRUCTOR ˜Rat(){ // nothing to do } + + | | hhhhhhh hhhhhhh 1/7/106 AT&T FOIL 19 | | + + // SELECTORS & CONST MEMBER FUNCTIONS int numer() const { return num; } double decimal() const { return double(num)/double(den); } int denom() const { return den; } int sign() const { if (num < 0) return -1; else return 1 // ..
Recommended publications
  • Typology of Programming Languages E Early Languages E
    Typology of programming languages e Early Languages E Typology of programming languages Early Languages 1 / 71 The Tower of Babel Typology of programming languages Early Languages 2 / 71 Table of Contents 1 Fortran 2 ALGOL 3 COBOL 4 The second wave 5 The finale Typology of programming languages Early Languages 3 / 71 IBM Mathematical Formula Translator system Fortran I, 1954-1956, IBM 704, a team led by John Backus. Typology of programming languages Early Languages 4 / 71 IBM 704 (1956) Typology of programming languages Early Languages 5 / 71 IBM Mathematical Formula Translator system The main goal is user satisfaction (economical interest) rather than academic. Compiled language. a single data structure : arrays comments arithmetics expressions DO loops subprograms and functions I/O machine independence Typology of programming languages Early Languages 6 / 71 FORTRAN’s success Because: programmers productivity easy to learn by IBM the audience was mainly scientific simplifications (e.g., I/O) Typology of programming languages Early Languages 7 / 71 FORTRAN I C FIND THE MEAN OF N NUMBERS AND THE NUMBER OF C VALUES GREATER THAN IT DIMENSION A(99) REAL MEAN READ(1,5)N 5 FORMAT(I2) READ(1,10)(A(I),I=1,N) 10 FORMAT(6F10.5) SUM=0.0 DO 15 I=1,N 15 SUM=SUM+A(I) MEAN=SUM/FLOAT(N) NUMBER=0 DO 20 I=1,N IF (A(I) .LE. MEAN) GOTO 20 NUMBER=NUMBER+1 20 CONTINUE WRITE (2,25) MEAN,NUMBER 25 FORMAT(11H MEAN = ,F10.5,5X,21H NUMBER SUP = ,I5) STOP TypologyEND of programming languages Early Languages 8 / 71 Fortran on Cards Typology of programming languages Early Languages 9 / 71 Fortrans Typology of programming languages Early Languages 10 / 71 Table of Contents 1 Fortran 2 ALGOL 3 COBOL 4 The second wave 5 The finale Typology of programming languages Early Languages 11 / 71 ALGOL, Demon Star, Beta Persei, 26 Persei Typology of programming languages Early Languages 12 / 71 ALGOL 58 Originally, IAL, International Algebraic Language.
    [Show full text]
  • Cobol/Cobol Database Interface.Htm Copyright © Tutorialspoint.Com
    CCOOBBOOLL -- DDAATTAABBAASSEE IINNTTEERRFFAACCEE http://www.tutorialspoint.com/cobol/cobol_database_interface.htm Copyright © tutorialspoint.com As of now, we have learnt the use of files in COBOL. Now, we will discuss how a COBOL program interacts with DB2. It involves the following terms: Embedded SQL DB2 Application Programming Host Variables SQLCA SQL Queries Cursors Embedded SQL Embedded SQL statements are used in COBOL programs to perform standard SQL operations. Embedded SQL statements are preprocessed by SQL processor before the application program is compiled. COBOL is known as the Host Language. COBOL-DB2 applications are those applications that include both COBOL and DB2. Embedded SQL statements work like normal SQL statements with some minor changes. For example, that output of a query is directed to a predefined set of variables which are referred as Host Variables. An additional INTO clause is placed in the SELECT statement. DB2 Application Programming Following are rules to be followed while coding a COBOL-DB2 program: All the SQL statements must be delimited between EXEC SQL and END-EXEC. SQL statements must be coded in Area B. All the tables that are used in a program must be declared in the Working-Storage Section. This is done by using the INCLUDE statement. All SQL statements other than INCLUDE and DECLARE TABLE must appear in the Procedure Division. Host Variables Host variables are used for receiving data from a table or inserting data in a table. Host variables must be declared for all values that are to be passed between the program and the DB2. They are declared in the Working-Storage Section.
    [Show full text]
  • A Politico-Social History of Algolt (With a Chronology in the Form of a Log Book)
    A Politico-Social History of Algolt (With a Chronology in the Form of a Log Book) R. w. BEMER Introduction This is an admittedly fragmentary chronicle of events in the develop­ ment of the algorithmic language ALGOL. Nevertheless, it seems perti­ nent, while we await the advent of a technical and conceptual history, to outline the matrix of forces which shaped that history in a political and social sense. Perhaps the author's role is only that of recorder of visible events, rather than the complex interplay of ideas which have made ALGOL the force it is in the computational world. It is true, as Professor Ershov stated in his review of a draft of the present work, that "the reading of this history, rich in curious details, nevertheless does not enable the beginner to understand why ALGOL, with a history that would seem more disappointing than triumphant, changed the face of current programming". I can only state that the time scale and my own lesser competence do not allow the tracing of conceptual development in requisite detail. Books are sure to follow in this area, particularly one by Knuth. A further defect in the present work is the relatively lesser availability of European input to the log, although I could claim better access than many in the U.S.A. This is regrettable in view of the relatively stronger support given to ALGOL in Europe. Perhaps this calmer acceptance had the effect of reducing the number of significant entries for a log such as this. Following a brief view of the pattern of events come the entries of the chronology, or log, numbered for reference in the text.
    [Show full text]
  • Modern Programming Languages CS508 Virtual University of Pakistan
    Modern Programming Languages (CS508) VU Modern Programming Languages CS508 Virtual University of Pakistan Leaders in Education Technology 1 © Copyright Virtual University of Pakistan Modern Programming Languages (CS508) VU TABLE of CONTENTS Course Objectives...........................................................................................................................4 Introduction and Historical Background (Lecture 1-8)..............................................................5 Language Evaluation Criterion.....................................................................................................6 Language Evaluation Criterion...................................................................................................15 An Introduction to SNOBOL (Lecture 9-12).............................................................................32 Ada Programming Language: An Introduction (Lecture 13-17).............................................45 LISP Programming Language: An Introduction (Lecture 18-21)...........................................63 PROLOG - Programming in Logic (Lecture 22-26) .................................................................77 Java Programming Language (Lecture 27-30)..........................................................................92 C# Programming Language (Lecture 31-34) ...........................................................................111 PHP – Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)........................129 Modern Programming Languages-JavaScript
    [Show full text]
  • The Machine That Builds Itself: How the Strengths of Lisp Family
    Khomtchouk et al. OPINION NOTE The Machine that Builds Itself: How the Strengths of Lisp Family Languages Facilitate Building Complex and Flexible Bioinformatic Models Bohdan B. Khomtchouk1*, Edmund Weitz2 and Claes Wahlestedt1 *Correspondence: [email protected] Abstract 1Center for Therapeutic Innovation and Department of We address the need for expanding the presence of the Lisp family of Psychiatry and Behavioral programming languages in bioinformatics and computational biology research. Sciences, University of Miami Languages of this family, like Common Lisp, Scheme, or Clojure, facilitate the Miller School of Medicine, 1120 NW 14th ST, Miami, FL, USA creation of powerful and flexible software models that are required for complex 33136 and rapidly evolving domains like biology. We will point out several important key Full list of author information is features that distinguish languages of the Lisp family from other programming available at the end of the article languages and we will explain how these features can aid researchers in becoming more productive and creating better code. We will also show how these features make these languages ideal tools for artificial intelligence and machine learning applications. We will specifically stress the advantages of domain-specific languages (DSL): languages which are specialized to a particular area and thus not only facilitate easier research problem formulation, but also aid in the establishment of standards and best programming practices as applied to the specific research field at hand. DSLs are particularly easy to build in Common Lisp, the most comprehensive Lisp dialect, which is commonly referred to as the “programmable programming language.” We are convinced that Lisp grants programmers unprecedented power to build increasingly sophisticated artificial intelligence systems that may ultimately transform machine learning and AI research in bioinformatics and computational biology.
    [Show full text]
  • Standards for Computer Aided Manufacturing
    //? VCr ~ / Ct & AFML-TR-77-145 )R^ yc ' )f f.3 Standards for Computer Aided Manufacturing Office of Developmental Automation and Control Technology Institute for Computer Sciences and Technology National Bureau of Standards Washington, D.C. 20234 January 1977 Final Technical Report, March— December 1977 Distribution limited to U.S. Government agencies only; Test and Evaluation Data; Statement applied November 1976. Other requests for this document must be referred to AFML/LTC, Wright-Patterson AFB, Ohio 45433 Manufacturing Technology Division Air Force Materials Laboratory Wright-Patterson Air Force Base, Ohio 45433 . NOTICES When Government drawings, specifications, or other data are used for any purpose other than in connection with a definitely related Government procurement opera- tion, the United States Government thereby incurs no responsibility nor any obligation whatsoever; and the fact that the Government may have formulated, furnished, or in any way supplied the said drawing, specification, or other data, is not to be regarded by implication or otherwise as in any manner licensing the holder or any person or corporation, or conveying any rights or permission to manufacture, use, or sell any patented invention that may in any way be related thereto Copies of this report should not be returned unless return is required by security considerations, contractual obligations, or notice on a specified document This final report was submitted by the National Bureau of Standards under military interdepartmental procurement request FY1457-76 -00369 , "Manufacturing Methods Project on Standards for Computer Aided Manufacturing." This technical report has been reviewed and is approved for publication. FOR THE COMMANDER: DtiWJNlb L.
    [Show full text]
  • ALGORITHMS for ARTIFICIAL INTELLIGENCE in Apl2 By
    MAY 1986 REVISED Nov­ 1986 TR 03·281 ALGORITHMS FOR ARTIFICIAL INTELLIGENCE IN APl2 By DR­ JAMES A· BROWN ED EUSEBI JANICE COOK lEO H­ GRONER INTERNATIONAL BUSINESS MACHINES CORPORATION GENERAL PRODUCTS DIVISION SANTA TERESA LABORATORY SAN JOSE~ CALIFORNIA ABSTRACT Many great advances in science and mathematics were preceded by notational improvements. While a g1yen algorithm can be implemented in any general purpose programming language, discovery of algorithms is heavily influenced by the notation used to Lnve s t Lq a t.e them. APL2 c o nce p t.ua Lly applies f unc t Lons in parallel to arrays of data and so is a natural notation in which to investigate' parallel algorithins. No c LaLm is made that APL2 1s an advance in notation that will precede a breakthrough in Artificial Intelligence but it 1s a new notation that allows a new view of the pr-obl.ems in AI and their solutions. APL2 can be used ill problems tractitionally programmed in LISP, and is a possible implementation language for PROLOG-like languages. This paper introduces a subset of the APL2 notation and explores how it can be applied to Artificial Intelligence. 111 CONTENTS Introduction. • • • • • • • • • • 1 Part 1: Artificial Intelligence. • • • 2 Part 2: Logic... · • 8 Part 3: APL2 ..... · 22 Part 4: The Implementations . · .40 Part 5: Going Beyond the Fundamentals .. • 61 Summary. .74 Conclus i ons , . · .75 Acknowledgements. • • 76 References. · 77 Appendix 1 : Implementations of the Algorithms.. 79 Appendix 2 : Glossary. • • • • • • • • • • • • • • • • 89 Appendix 3 : A Summary of Predicate Calculus. · 95 Appendix 4 : Tautologies. · 97 Appendix 5 : The DPY Function.
    [Show full text]
  • 10 Programming Languages You Should Learn Right Now by Deborah Rothberg September 15, 2006 8 Comments Posted Add Your Opinion
    10 Programming Languages You Should Learn Right Now By Deborah Rothberg September 15, 2006 8 comments posted Add your opinion Knowing a handful of programming languages is seen by many as a harbor in a job market storm, solid skills that will be marketable as long as the languages are. Yet, there is beauty in numbers. While there may be developers who have had riches heaped on them by knowing the right programming language at the right time in the right place, most longtime coders will tell you that periodically learning a new language is an essential part of being a good and successful Web developer. "One of my mentors once told me that a programming language is just a programming language. It doesn't matter if you're a good programmer, it's the syntax that matters," Tim Huckaby, CEO of San Diego-based software engineering company CEO Interknowlogy.com, told eWEEK. However, Huckaby said that while his company is "swimmi ng" in work, he's having a nearly impossible time finding recruits, even on the entry level, that know specific programming languages. "We're hiring like crazy, but we're not having an easy time. We're just looking for attitude and aptitude, kids right out of school that know .Net, or even Java, because with that we can train them on .Net," said Huckaby. "Don't get fixated on one or two languages. When I started in 1969, FORTRAN, COBOL and S/360 Assembler were the big tickets. Today, Java, C and Visual Basic are. In 10 years time, some new set of languages will be the 'in thing.' …At last count, I knew/have learned over 24 different languages in over 30 years," Wayne Duqaine, director of Software Development at Grandview Systems, of Sebastopol, Calif., told eWEEK.
    [Show full text]
  • INTRODUCTION to PL/1 PL/I Is a Structured Language to Develop Systems and Applications Programs (Both Business and Scientific)
    INTRODUCTION TO PL/1 PL/I is a structured language to develop systems and applications programs (both business and scientific). Significant features : v Allows Free format v Regards a program as a continuous stream of data v Supports subprogram and functions v Uses defaults 1 Created by Sanjay Sinha Building blocks of PL/I : v Made up of a series of subprograms and called Procedure v Program is structured into a MAIN program and subprograms. v Subprograms include subroutine and functions. Every PL/I program consists of : v At least one Procedure v Blocks v Group 2 Created by Sanjay Sinha v There must be one and only one MAIN procedure to every program, the MAIN procedure statement consists of : v Label v The statement ‘PROCEDURE OPTIONS (MAIN)’ v A semicolon to mark the end of the statement. Coding a Program : 1. Comment line(s) begins with /* and ends with */. Although comments may be embedded within a PL/I statements , but it is recommended to keep the embedded comments minimum. 3 Created by Sanjay Sinha 2. The first PL/I statement in the program is the PROCEDURE statement : AVERAGE : PROC[EDURE] OPTIONS(MAIN); AVERAGE -- it is the name of the program(label) and compulsory and marks the beginning of a program. OPTIONS(MAIN) -- compulsory for main programs and if not specified , then the program is a subroutine. A PL/I program is compiled by PL/I compiler and converted into the binary , Object program file for link editing . 4 Created by Sanjay Sinha Advantages of PL/I are : 1. Better integration of sets of programs covering several applications.
    [Show full text]
  • Event Management for the Development of Multi-Agent Systems Using Logic Programming
    Event Management for the Development of Multi-agent Systems using Logic Programming Natalia L. Weinbachy Alejandro J. Garc´ıa [email protected] [email protected] Laboratorio de Investigacio´n y Desarrollo en Inteligencia Artificial (LIDIA) Departamento de Ciencias e Ingenier´ıa de la Computacio´n Universidad Nacional del Sur Av. Alem 1253, (8000) Bah´ıa Blanca, Argentina Tel: (0291) 459-5135 / Fax: (0291) 459-5136 Abstract In this paper we present an extension of logic programming including events. We will first describe our proposal for specifying events in a logic program, and then we will present an implementation that uses an interesting communication mechanism called \signals & slots". The idea is to provide the application programmer with a mechanism for handling events. In our design we consider how to define an event, how to indicate the occurrence of an event, and how to associate an event with a service predicate or handler. Keywords: Event Management. Event-Driven Programming. Multi-agent Systems. Logic Programming. 1 Introduction An event represents the occurrence of something interesting for a process. Events are useful in those applications where pieces of code can be executed automatically when some condition is true. Therefore, event management is helpful to develop agents that react to certain occurrences produced by changes in the environment or caused by another agents. Our aim is to support event management in logic programming. An event can be emitted as a result of the execution of certain predicates, and will result in the execution of the service predicate or handler. For example, when programming a robot behaviour, an event could be associated with the discovery of an obstacle in its trajectory; when this event occurs (generated by some robot sensor), the robot might be able to react to it executing some kind of evasive algorithm.
    [Show full text]
  • S-Algol Reference Manual Ron Morrison
    S-algol Reference Manual Ron Morrison University of St. Andrews, North Haugh, Fife, Scotland. KY16 9SS CS/79/1 1 Contents Chapter 1. Preface 2. Syntax Specification 3. Types and Type Rules 3.1 Universe of Discourse 3.2 Type Rules 4. Literals 4.1 Integer Literals 4.2 Real Literals 4.3 Boolean Literals 4.4 String Literals 4.5 Pixel Literals 4.6 File Literal 4.7 pntr Literal 5. Primitive Expressions and Operators 5.1 Boolean Expressions 5.2 Comparison Operators 5.3 Arithmetic Expressions 5.4 Arithmetic Precedence Rules 5.5 String Expressions 5.6 Picture Expressions 5.7 Pixel Expressions 5.8 Precedence Table 5.9 Other Expressions 6. Declarations 6.1 Identifiers 6.2 Variables, Constants and Declaration of Data Objects 6.3 Sequences 6.4 Brackets 6.5 Scope Rules 7. Clauses 7.1 Assignment Clause 7.2 if Clause 7.3 case Clause 7.4 repeat ... while ... do ... Clause 7.5 for Clause 7.6 abort Clause 8. Procedures 8.1 Declarations and Calls 8.2 Forward Declarations 2 9. Aggregates 9.1 Vectors 9.1.1 Creation of Vectors 9.1.2 upb and lwb 9.1.3 Indexing 9.1.4 Equality and Equivalence 9.2 Structures 9.2.1 Creation of Structures 9.2.2 Equality and Equivalence 9.2.3 Indexing 9.3 Images 9.3.1 Creation of Images 9.3.2 Indexing 9.3.3 Depth Selection 9.3.4 Equality and Equivalence 10. Input and Output 10.1 Input 10.2 Output 10.3 i.w, s.w and r.w 10.4 End of File 11.
    [Show full text]
  • A Block Design for Introductory Functional Programming in Haskell
    A Block Design for Introductory Functional Programming in Haskell Matthew Poole School of Computing University of Portsmouth, UK [email protected] Abstract—This paper describes the visual design of blocks for the learner, and to avoid syntax and type-based errors entirely editing code in the functional language Haskell. The aim of the through blocks-based program construction. proposed blocks-based environment is to support students’ initial steps in learning functional programming. Expression blocks and There exists some recent work in representing functional slots are shaped to ensure constructed code is both syntactically types within blocks-based environments. TypeBlocks [9] in- correct and preserves conventional use of whitespace. The design cludes three basic type connector shapes (for lists, tuples aims to help students learn Haskell’s sophisticated type system and functions) which can be combined in any way and to which is often regarded as challenging for novice functional any depth. The prototype blocks editor for Bootstrap [10], programmers. Types are represented using text, color and shape, [11] represents each of the five types of a simple functional and empty slots indicate valid argument types in order to ensure language using a different color, with a neutral color (gray) that constructed code is well-typed. used for polymorphic blocks; gray blocks change color once their type has been determined during program construction. I. INTRODUCTION Some functional features have also been added to Snap! [12] Blocks-based environments such as Scratch [1] and Snap! and to a modified version of App Inventor [13]. [2] offer several advantages over traditional text-based lan- This paper is structured as follows.
    [Show full text]