I just got it! (invariant/const)

Lionello Lunesu lionello at lunesu.remove.com
Wed Apr 9 19:30:49 PDT 2008


"Jason House" <jason.james.house at gmail.com> wrote in message 
news:ftislk$3m0$1 at digitalmars.com...
> Janice Caron Wrote:
>
>> On 09/04/2008, Georg Wrede <georg at nospam.org> wrote:
>> >  This is even stronger than (1) above, it is clearer,
>> >  and it's *right*.
>>
>> Sure, but you don't need to outlaw code that does nothing. :-)
>
> D already outlaws having code that isn't run.  I would prefer for code 
> that does nothing to be considered an error.  Of course, with most 
> functions being impure, that's tough to enforce.  With pure functions, it 
> should be easy.

Why? If pure-ness (uh, purity?) can be checked, it can also be deducted (*), 
so the compiler could optimize/complain in either case.

Tagging a function explicitely as "pure" would only enable a constraint as 
to what other functions can be called, which is something I'd rather see 
solved using more generalized tagging abilities (See Scott Meyers' 
presentation on red-code, green-code [1]).

Maybe identifiers between the parameter list and the function body could 
work as ad-hoc constraints. This would work for pure and nothrow, and the 
user can add whatever identifier/constraint s/he wants.

L.

(*) Is this conclusion correct? It feels correct, but I don't think I can 
proof it.

[1] http://www.nwcpp.org/Downloads/2007/redcode_-_updated.pdf 




More information about the Digitalmars-d mailing list