To help LDC/GDC
Simen Kjærås
simen.kjaras at gmail.com
Tue Apr 9 01:43:58 PDT 2013
On Tue, 09 Apr 2013 10:33:45 +0200, Manu <turkeyman at gmail.com> wrote:
> On 9 April 2013 18:04, Dicebot <m.strashun at gmail.com> wrote:
>
>> On Tuesday, 9 April 2013 at 07:57:37 UTC, Manu wrote:
>>
>>> Are you saying the example above is not actually valid code?
>>>
>>> struct Foo {
>>> int a = 0;
>>> pure int bar( int n ) { // Weakly pure
>>> a += n;
>>> return a;
>>> }
>>> }
>>>
>>> That's not pure. Call it twice with the same args, you'll different
>>> answers. How can that possibly be considered pure in any sense?
>>> And it's useless in terms of optimisation, so why bother at all? What
>>> does
>>> it offer?
>>>
>>
>> It is valid code. It is "weak pure". "pure' keyword means both
>> "strong pure" or "weak pure" depending on function body. Crap.
>>
>
> How can 'weak pure' reasonably be called any kind of 'pure'?
It's pure in the sense that it can be used inside (strongly) pure
functions.
> I suggest that no D language newbie would ever reasonably expect that
> behaviour.
And with that, I absolutely have to agree.
--
Simen
More information about the Digitalmars-d
mailing list