1 / 13

Introduction to RPAL

Introduction to RPAL. Module 10.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez. The RPAL Language No assignment No sequencing No iteration No “memory” Only expressions: every RPAL program is an expression. To run an RPAL program is to evaluate it. “Turing complete”.

bradshawc
Download Presentation

Introduction to RPAL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to RPAL Module 10.1COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez

  2. The RPAL Language No assignment No sequencing No iteration No “memory” Only expressions: every RPAL program is an expression. To run an RPAL program is to evaluate it. “Turing complete” Topics

  3. PAL: Pedagogic Algorithmic Language. Developed by J. Wozencraft and A. Evans at MIT, early 70's. R(ight-reference)PAL ⊂ L(eft-reference)PAL ⊂ J(ump) PAL Intellectual ancestor of Scheme, (Guy Steele, mid-70's) Steele (Sun Microsystems): principal contributor to Java. Google: 'Guy Steele Scheme‘. Why Study RPAL ? Generic, “plain vanilla” functional language. Unknown language (to you)  Paradigm shift !! RPAL is a subset of PAL

  4. Simple one-line RPAL programs

  5. Integer operations: +, -, *, /, **, eq, ne, ls, <, gr, >, le, <=, ge, >= Truthvalue (boolean) operations: or, &, not, eq, ne String operations: eq, ne, Stem S, Stern S, Conc S T Conditional operator: -> | Elementary values: <int>, <id>, true, false data types and operators

  6. operator Precedence Operator Precedence Associativity -> Low Right or Left & Left not None gr ge le ls eq ne None + - (unary and binary) Left * / Left ** Right () High Embedded • Elements: <id>, <int>, <str>, true, false, dummy

  7. Has a ’bound variable’ (parameter), and a body. Example: fn X. Print(X**2) It’s value: “Nameless, typeless function with typeless parameter X, that prints X squared.” fn N. N ls 0 -> -N | N Value: “Nameless, typeless function with typeless parameter N, that returns |N|.” fn x. fn y.x+y or, equivalently fn x y.x+y Value: “Nameless, typeless function that takes typeless parameter x, and returns nameless, New data type: function (fn x. B) typeless function that take typeless parameter y, and returns x+y.”

  8. Function application is by juxtaposition. Example: (fn X. Print(X**2)) 3 Function is applied to 3. 3 replaces X in expression Print(X**2),yielding Print(3**2), yielding Print(9), yielding dummy (and prints 9). Function application

  9. Example: (fn N. N ls 0 -> -N | N) (-3) (-3) replaces N in (N ls 0 -> -N | N), yielding ((-3) ls 0 -> -(-3)|(-3)) ), yielding –(-3) = 3 Function application is left associative: Example: (fn x. fn y.x+y) 3 2 yielding (fn y.3+y) 2 yielding 3+2 yielding 5 Function application

  10. Intrinsic functions. Applied to a value, return true or false: Isinteger x Istruthvalue x Isstring x Istuple x Isfunction x Isdummy x Type Identification Functions

  11. Operators Function definitions Constant definitions (parameterless function) Conditional expressions Function application Recursion Rpal constructs

  12. Integer Truthvalue (boolean) String Tuple (coming soon) Function Dummy (value: dummy) RPAL is dynamically typed: the type of an expression is determined at run-time. Example: let Funny = (B -> 1 | ’January’) in Print(Funny) RPAL Has Six Data Types:

  13. summary • RPAL • Language of expressions • To run it, evaluate it. • Arithmetic, boolean, string operations. • New data type: function. • New operation: function application.

More Related