[nem-en] Non short-circuiting logical operators
Vladimir Matveev
desco.by at gmail.com
Wed Jan 31 16:03:44 CET 2007
Are analogues of c# non short-circuiting logical operators (|, &) for bool
exists in Nemerle?
[c#]
class Program
{
static bool GetA()
{
Console.WriteLine("GetA");
return true;
}
static bool GetB()
{
Console.WriteLine("GetB");
return true;
}
static void Main(string[] args)
{
// simple form
Console.WriteLine(GetA() | GetB()); // prints GetA GetB True
// short-circuiting form
Console.WriteLine(GetA() || GetB()); // prints GetA True
}
}
[/c#]
[nemerle]
module Program
{
GetA() : bool
{
WriteLine("GetA");
true
}
GetB() : bool
{
WriteLine("GetB");
false
}
Main() : void
{
WriteLine(GetA() | GetB()); // error: cannot find the operator
`op_BitwiseOr' on bool and bool
WriteLine(GetA() || GetB()); // prints GetA True
}
}
[/nemerle]
More information about the devel-en
mailing list