To help LDC/GDC

Iain Buclaw ibuclaw at ubuntu.com
Thu Apr 11 06:49:02 PDT 2013


On 11 April 2013 11:09, Simen Kjærås <simen.kjaras at gmail.com> wrote:

> On Thu, 11 Apr 2013 12:03:38 +0200, deadalnix <deadalnix at gmail.com> 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';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130411/c3bb1f0a/attachment.html>


More information about the Digitalmars-d mailing list