My body is ugly [Re: Contextualizing keywords]

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Mon Aug 3 04:53:03 PDT 2009


>>> I think this is much more elegant:
>>>
>>> # int foo(int a) {
>>> #    in {
>>> #       assert(a>2);
>>> #    }
>>> #
>>> #    return a-1;
>>> # }
>> 
>> I have to disagree. That suggests that 'in' is a scope within the body,
>> which would have access to its local variables. Of course, it shouldn't.
> 
> If you make 'in' clauses 'pure' (which they are, conceptually), it works
> fine.

But 'in' still needs read-access to the actual parameters and every visible
symbol in a scope shallower than that of the function.

> I agree with Pete, I think that's a greatly superior syntax to what we
> have now.

Then I assume you still want to restrict the precondition to being the first
element in the body? Because putting it in there suggests that it may
appear anywhere a statement can.

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list