Thursday, April 29, 2010

Aum Syntax Samples: constrained domains

Working on contrained types(domains) idea, proposed syntax:
--------------------------------------------


use
RTL;

scope Test begin

//Domain with constrain
public domain HumanAge(int)
{
value >= 0 and value <= 150; }

public static class Program1 begin
public method Main
{
Console.WriteLine("Hello Delphi days!");
Console.ReadLine();
Console.WriteLine("About to crash");
var age: HumanAge;
age = 500; // CRASH!!!!!! Domain is constrained and did not pass validation
}

end;


end;