My body is ugly [Re: Contextualizing keywords]
Don
nospam at nospam.com
Mon Aug 3 08:47:49 PDT 2009
Michiel Helvensteijn wrote:
> Don wrote:
>
>> It would be strange to put outer function statements before the
>> precondition, but that's true of any inner function.
>
> I don't see it as an inner function, but as a part of the public interface.
> It's an enforceable documentation of the function.
I agree, except that I don't see any reason why a special inner function
cannot be part of the public interface. I don't think it makes any
difference where it is appears in the code.
In my experience, most of the code in the precondition frequently gets
duplicated in the function itself. But that's secondary -- I just want
to get rid of 'body'.
The stronger argument against the 'inner function' syntax is the case
when you have an interface, which naturally has no body, but still has
an 'in' contract. Where does the contract go?
I refuse to believe that the optimal solution to that problem involves
the 'body' keyword.
More information about the Digitalmars-d
mailing list