CSE 505 -- Very Rough Notes on Higher Order Functions in Pizza

November 1999

Higher-order functions supported in Pizza

These are available in Algol 60, although not as first-class citizens

used pervasively in languages like Smalltalk, Miranda, Scheme

EXAMPLE:

int n;
(int) -> int f;
(char,int) -> bool g;
() -> int h;


f, g, h are variables that hold functions

f = fun (int k)->int { return k+1};

n = f(5);

also see Radix example in Pizza paper


NON-LOCAL VARIABLES IN THE FUNCTIONS:


class Squid {
  public int n = 0;
  public (int) -> int inc() {
    return fun (int k) -> int {
      return n+k;
      }
    }
}

squid s;
int i,j,k;
(int) -> int f;

s = new Squid();
f = s.inc();
i = f(3);
s.n = 10;
j = f(3);