Changes between Version 4 and Version 5 of PIL


Ignore:
Timestamp:
10/03/24 20:42:43 (20 months ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PIL

    v4 v5  
    4747
    4848There are two kinds of functions in PIL:
    49 1. Imperative functions = "procedures"
    50 1. Logic functions
     491. Imperative functions = "procedures".  A procedure has a type of the form `R(T1,...,Tn)` where `R` is the return type and the Ti are the input types.
     501. Logic functions.  One of these has a type of the form `$fun<R,T1,...,Tn>`.
    5151
    5252=== Procedures
    5353
    54 Like in C.  These can be nested.  Obviously they can have side-effects, be nondeterministic, and the behavior can depend on non-local state.  A procedure call `f(x1,...,xn)` is an expression that can be used anywhere an expression with side-effects is allowed.  Imperative procedures are not values and cannot be assigned to anything.  However, as in C, a pointer to a procedure is a first-class value that can be assigned, used as an argument, returned, etc.   There is a procedure type, exactly like C's function type, e.g.,
     54Like in C.  These can be nested.  Obviously they can have side-effects, be nondeterministic, and the behavior can depend on non-local state.  A procedure call `f(x1,...,xn)` is an expression that can be used anywhere an expression with side-effects is allowed.  Imperative procedures are not values and cannot be assigned to anything.  However, as in C, a pointer to a procedure is a first-class value that can be assigned, used as an argument, returned, etc.   There is a procedure type, similar to C's function type, e.g.,
    5555{{{
    5656       typedef int(int) i2i;
     
    6060       typedef int(int)* i2ip;
    6161}}}
    62 defines the type "pointer to procedure from int to int".  As in C, a pointer to a procedure can be used in a procedure call.
     62defines the type "pointer to procedure from int to int".  As in C, a pointer to a procedure can be used in a procedure call.  It is an error to call a procedure f when f is not in scope.  (This is similar to Gnu C.)   In other words, if the call takes place in dyscope d, then the definition of f must be in d's static scope, or in the parent of d's static scope, or its parent, etc.
    6363
    6464A procedure definition can be templated:
     
    7070=== Logic functions
    7171
    72 Typically specified by a $lambda expression. These are first-class objects in PIL: they can be assigned to variables, passed as an argument in a function call (including a procedure call), and can be returned by a function.  Each has a type of the form `$fun<U,T1,...,Tn>` (functions from `T1` x ... x `Tn` to `U`).  They are side-effect-free.  An application of a logic function `f(x1,...,xn)` is an expression that can be used anywhere an expression is allowed.  A logic function is not necessarily pure, i.e., the value of an application may depend on any part of the state, not just the arguments.
     72Typically specified by a $lambda expression. These are first-class objects in PIL: one can be assigned to a variable, passed as an argument in a function call (including a procedure call), and can be returned by a function.  Each has a type of the form `$fun<U,T1,...,Tn>` (functions from `T1` x ... x `Tn` to `U`).  They are side-effect-free.  An application of a logic function `f(x1,...,xn)` is a side-effect-free expression that can be used anywhere an expression is allowed.  A logic function is not necessarily pure, i.e., the value of an application may depend on any part of the state, not just the arguments.
    7373 
    7474=== Lambda expressions