1.44. Procedure Values Again

We've seen the advantages of higher order functions and procedures. It is possible to define anonymous procedure and function values literally, as in the next example, they're called lambdas, after the lambda calculus:
Start C++ section to tut/examples/tut154.flx[1 /1 ]
     1: include "std";
     2: val f = fun(a:int):int = { return a * a; };
     3: 
     4: print (f 1);
     5: endl;
     6: 
     7: print
     8: (
     9:   (fun(a:int):int = { return a * a; })
    10:   1
    11: );
    12: endl;
    13: 
    14: proc thrice(p:unit->void) { p(); p(); p(); }
    15: thrice ( proc() { print 3; endl; } );
    16: thrice ( proc   { print 3; endl; } );
    17: thrice          { print 3; endl; };
    18: { print "finished"; endl; };
    19: 
End C++ section to tut/examples/tut154.flx[1]
Mickey Mouse! Checkout the shortcut on the second last line. You can just write statements in curly brackets for an anonymous procedure taking unit argument, you can leave off the
  proc() // or
  proc
But why does the last line work? The answer is: this is a special shortcut. A statement consisting of an anonymous procedure taking unit, and a semicolon ; is a shortcut for a call:
  { print 1; }; // is a shortcut for ..
  { print 1; } ();
much the same as
  endl; // is a shortcut for ..
  endl ();
Now, remember those ugly semicolons at the end of the while statement? Are you getting a glimmer? Hint: Felix doesn't have a while statement. It's a library routine!