My body is ugly [Re: Contextualizing keywords]

grauzone none at example.net
Mon Aug 3 23:50:23 PDT 2009


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; }



More information about the Digitalmars-d mailing list