contract programming without a function

Bruno Medeiros brunodomedeiros+spam at com.gmail
Sat May 26 08:18:43 PDT 2007


Frits van Bommel wrote:
> Derek Parnell wrote:
>> I don't believe that 'in' and 'out' can yet be used for nested 
>> functions or
>> anonymous functions.
> 
> It works fine for nested functions:
> ---
> import std.stdio;
> 
> void main()
> {
>     void nested()
>     in {
>         writefln("nested : in");
>     } out {
>         writefln("nested : out");
>     } body {
>         writefln("nested : body");
>     }
> 
>     nested();
> }
> ---
> 
> You seem to be right about anonymous functions though.

It works fine for anonymous functions too:
----
void main(char[][] args) {
     function void ()
     in {
         writefln("nested : in");
     } out {
         writefln("nested : out");
     } body {
         writefln("nested : body");
     } ();
	
	writeln("END");
}
----
One just is not able to use the shortened anonymous function syntax.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D


More information about the Digitalmars-d-learn mailing list