Le 20/06/2012 17:24, Timon Gehr a écrit :
On 06/20/2012 05:17 PM, deadalnix wrote:
Le 20/06/2012 16:55, Timon Gehr a écrit :
It works if implicit conversions from 'R delegate(A)' to
'R delegate(A) const' are allowed, as well as looking up an
'R delegate(A) in a const receiver object.

What about conversion from/to immutable ?

Simple application of transitivity. This part is the same for 1./2.

'R delegate(A)' and 'R delegate(A) const' are not convertible to
'R delegate(A) immutable', but 'R delegate(A) immutable' is
convertible to 'R delegate(A)' and 'R delegate(A) const'.

'R delegate(A)' and 'R delegate(A) const' decay to
'R delegate(A) immutable' when stored in an immutable object.


I've gone through a similar reasoning. It does not work.

Yes it does.

Here are implicit casts summed up :

mutable -> const
immutable -> const
immutable -> mutable

which implicitely imply immutable -> const

And then you add when storing in immutable object.

mutable -> immutable
const -> immutable


These are not valid implicit conversions.

What I meant was:

struct S{
R delegate(A) mutable;
R delegate(B)const const_;
}

static assert(is(typeof(immutable(S).mutable)==R delegate(A) immutable));
static assert(is(typeof(immutable(S).const_)==R delegate(A) immutable));


It means that you can store a delegate that have a mutable frame pointer
into an immutable object, which break transitivity.

No.

OK I understand.

This is consistent for the frame pointer type qualifier. But not for the function pointer. Remember that the function pointer accept the frame pointer as argument.

This set of rule prevent safe closure rebinding.

Reply via email to