please is an strongly-typed, garbage-collected imperative programming language. The name of the language is an acronym for "Programming Language Expecting Abstact Set Expressions". (It is also known, perhaps somewhat more affectionately, as "Please Let Expressions About Sets Execute".)
please programs consists of zero or more declarations, followed by precisely one statement. (That may sounds trivial, but declarations, as made apparent below, can consist of arbitrarily nested functions and procedures, and the solo statement can itself be a block which can consist of more declarations and statements.)
please programs do not take any arguments.
A declaration can be in one of four forms:
int $count;
pair<string,bool> $p;
set{set{int}} $setOfSets;
array[string] $alias;
Note the last example, an array declaration without an allocation
refers to an array that will be used as pointer.
array[int] $a[13];
array[string] $beta[$i];
array[set{bool}] $c3po[2*(sizeof $s)];
fun add(int $i, int $j) : $int {
int $sum;
$sum := $i + $j;
return $sum;
}
proc reset(array[int] $a) {
int $i;
$i := 0;
while $i < sizeof $a do {
$a[$i] := 0;
$i := $i + 1;
}
}
Observe, procedures are just like functions except they have no return type.
A statement may take one of several forms:
$x := "hello"; $a[$i] := $y * 3; $matrix[$i][$j] := 7;
if $a < $b then {
$max := $b;
} else {
$max := $a;
}
while $n > 0 {
$fact := $n * $fact;
$n := $n - 1;
}
foreach $x in $s do {
$a[$i] := $x;
$i := $i + 1;
}
reset($a); copyArray($arr0, $arr1);
{ } // empty blocks are okay!
{
int $temp;
$temp := $x;
$x := $y;
$y := $temp;
}
pair<string,bool>
pair<set{int},array[set{string}]>
array[int]
array[string]
array[set{bool}]
set{string} $names;
set{set{int}} $setOfSets;
set{pair<int,int>} $points;
The following expression-forming operators are not associative. Attempting to associate them should result in a syntax error (not a type error):
= > < >= <= first second sizeof grab in
Two unary operators, ~ and not associate to the right.
All other operators associate to the left.
The order of operators is, from highest to lowest, as follows:
[] ~ * / % + - sizeof first second grab = > < >= <= in not and or
$x $hello $_global_75 $WhatIsTheFrequency