Another idiom I wish were gone from phobos/druntime

Zach the Mystic via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 5 08:34:36 PST 2015


On Thursday, 5 February 2015 at 07:06:31 UTC, deadalnix wrote:
> On Thursday, 5 February 2015 at 04:36:39 UTC, Zach the Mystic 
> wrote:
>> I have an idea. Treat all assert statements which come before 
>> the first non-assert statement as part of the 'in' contract. 
>> I'm not saying the compiler has to generate a whole 'in' 
>> function, but these asserts can be internally tagged to behave 
>> *as if* in an 'in' contract. That solves the tooling problem 
>> and the too-much-code problem, no?
>
> No. There is no point of screwing up the language because an 
> arbitrary choice of formating is taking an absurd amount of 
> vertical space.

Screwing up the language? I'd be willing to accept your position 
if I could think of any possible instance in which:

T myFunc()
   assert(xxx);
   assert(yyy);
   doStuff();
}

... were not intended to be semantically equivalent to:

T myFunc()
in {
   assert(xxx);
   assert(yyy);
}
body {
   doStuff();
}

Can you name one, or even imagine one? Bear in mind people like 
Andrei and myself do not like to read or write the later form and 
will use it much less, regardless of benefit.


More information about the Digitalmars-d mailing list