To help LDC/GDC

deadalnix deadalnix at gmail.com
Thu Apr 11 03:37:25 PDT 2013


On Thursday, 11 April 2013 at 10:16:39 UTC, John Colvin wrote:
> On Thursday, 11 April 2013 at 10:03:39 UTC, deadalnix 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.
>
> is foo strongly pure because of n being a value type that 
> cannot contain any indirection? (i.e. as far as the outside 
> world is concerned you don't get any side effects whatever you 
> do with it).
>
> Is the same for structs that contain no indirection? Or do they 
> have to be const/immutable?

I don't know what the current implementation says, but it should 
be.


More information about the Digitalmars-d mailing list