How to break const

Christophe Travert travert at phare.normalesup.org
Tue Jun 19 02:47:23 PDT 2012


Iain Buclaw , dans le message (digitalmars.D:170145), a écrit :
> On 19 June 2012 09:18, Don Clugston <dac at nospam.com> wrote:
>> So would I. Can you think of one?
>> It was the best name I could come up with, given that the 'pure' was the
>> keyword.
>> We want a word that means 'no hidden state'.
> 
> I thought that was what pure was for. :~)
> 
> -- 
> Iain Buclaw
> 
> *(p < e ? p++ : p) = (c & 0x0f) + '0';


A delegate does have a frame pointer, and it's not that well hidden. If 
you want no such 'hidden state', you do not want a delegate, you want a 
function pointer. That means all delegates are weakly pure (until they 
have an immutable frame pointer qualifier).

If you want that this 'hidden state' does not change, that is another 
story. pure for a delegate could mean that the frame pointer does not 
change, but then, pure methods wouldn't allow you to make pure 
delegates:

struct S
{
  int i;
  int foo() pure { return i; }
}

S s;
int delegate() pure dg = &s.foo;
// error if pure change meaning when applied to a delegate



More information about the Digitalmars-d mailing list