On 11 April 2013 11:09, Simen Kjærås <[email protected]> wrote:
> On Thu, 11 Apr 2013 12:03:38 +0200, deadalnix <[email protected]> wrote: > > On Thursday, 11 April 2013 at 08:36:13 UTC, Joseph Rushton Wakeling wrote: >> >>> On 04/10/2013 08:39 PM, Walter Bright wrote: >>> >>>> Sure there is. Declare the function as pure, and the function's >>>> parameters as >>>> const or immutable. >>>> >>> >>> Sure, I accept that. What I was meaning, though, was an up-front >>> declaration >>> which would make the compiler shout if those necessary conditions were >>> not met. >>> >>> i.e. >>> >>> pure foo(int n) { ... } // compiles >>> >>> strong pure bar(int n) { ... } // compiler instructs you to make >>> // variables const or immutable >>> >> >> Both are strongly pure. >> > > That's not the point. The point is, if he'd written this: > > strong pure bar(int* n) { ... } > > The compiler would have said 'Bad programmer! int* is not implicitly > castable to immutable!' > Great, just what we need. A compiler that barrages the user about how bad his code is, then dies... </sarcasm> -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
