My body is ugly [Re: Contextualizing keywords]
Michel Fortin
michel.fortin at michelf.com
Tue Aug 4 02:13:17 PDT 2009
On 2009-08-04 02:50:23 -0400, grauzone <none at example.net> said:
> Michel Fortin wrote:
>> Also, I wonder why we need braces everywhere in contracts. I'd like it
>> if I could write:
>>
>>
>> int test(int i)
>> in
>> assert(i > 1);
>> out (z)
>> assert(z < 0);
>> do
>> return -i + 1;
>
> Just bikeshedding a bit around... why not make it even simpler, and
> just leave away the body/do completely? That would finally be a syntax
> I'd be happy with. It wouldn't destroy the normal code layout too,
> because in/out contracts are fully additional syntax.
>
> int test(int i)
> in assert(i > 1);
> out(z) assert(z < 0);
> { return -i + 1; }
That could work if the in and out blocks were alwasy one-statement
long. That's hardly the case, and so you'd have two blocks following
each other which I find a little strange:
int test(int i)
in {
assert(i > 1);
}
out (z) {
assert(z < 0);
}
{
return -i + 1;
}
Nothing catastrophic, but in my opinion it reads better with a keyword
in front of the last opening brace.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list