My body is ugly [Re: Contextualizing keywords]
Denis Koroskin
2korden at gmail.com
Mon Aug 3 05:15:54 PDT 2009
On Mon, 03 Aug 2009 15:53:03 +0400, Michiel Helvensteijn
<m.helvensteijn.remove at gmail.com> wrote:
>>>> 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.
>
Why not?
More information about the Digitalmars-d
mailing list