On 02/17/2012 06:47 AM, F i L wrote:
I would use them over '||' and '&&' for the reasons bearophile gave.
Highlighted as keywords, they're easily set appart, easier to type, and
more distinguished... then again if I had my way I'd remove the '('/')'
brackets, ending marks, and auto keyword; switched the definition
name-type placement and change if/else/return/contract syntax...
foo( a, b: float ): int
{
contract in
{
assert( a != 0 and b != 0 )
}
result: = a + b
case a >= b { ret result }
else b > a { ret a }
ret 0
}
writeLine: alias writeln
main()
{
a, b: float = 10.2, 5.0
writeLine( foo( a, b ) )
}
Tell me that's not beautiful code! :D
This looks a lot like rust. :o)
The contract syntax is wrong, because it conceptually has to belong to
the function declaration, not the function body.