digitalmars.D - Advanced const propagation for structs
- Ilya Yaroshenko (18/18) Oct 16 2016 Hi,
- Dicebot (26/51) Oct 16 2016 protected-headers="v1"
- Timon Gehr (5/8) Oct 16 2016 Actually, I did propose a solution before. Just allow annotations on
- Dicebot (15/24) Oct 16 2016 protected-headers="v1"
- Timon Gehr (4/15) Oct 17 2016 forum.dlang.org/post/lkfkel$2avp$1@digitalmars.com
- Nicholas Wilson (6/24) Oct 16 2016 Is there a way to say "the constness (and/or immutability) of
- Ilya Yaroshenko (2/34) Oct 16 2016 A workaround was found https://github.com/dlang/phobos/pull/4869
Hi, Extern precompiled Mir GLAS requires additional API changes. Reduced example: ```d struct S(T) { size_t len; T ptr; } auto foo(S!(const(double)*) sl) { } S!(double*) a; const S!(double*) b; foo(a); // fails foo(b); // fails ``` https://issues.dlang.org/show_bug.cgi?id=16616
Oct 16 2016
protected-headers="v1" From: Dicebot <public dicebot.lv> Newsgroups: d,i,g,i,t,a,l,m,a,r,s,.,D Subject: Re: Advanced const propagation for structs References: <tdsvyuhuamgfibbdszev forum.dlang.org> In-Reply-To: <tdsvyuhuamgfibbdszev forum.dlang.org> --MvFDN3d2B4TOF1p20oWssvIM6KtBXMW9o Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/16/2016 11:36 AM, Ilya Yaroshenko wrote:Hi, =20 Extern precompiled Mir GLAS requires additional API changes. Reduced example: =20 ```d struct S(T) { size_t len; T ptr; } =20 auto foo(S!(const(double)*) sl) { } =20 S!(double*) a; const S!(double*) b; =20 foo(a); // fails foo(b); // fails =20 ``` =20 https://issues.dlang.org/show_bug.cgi?id=3D16616This issue has been discussed before in context of custom containers and AFAIK so far no one was able to come up with even theoretical concept of how it can be possibly addressed. The issue is crazy complicated because of how D templates work: struct S (T) { static if (is(typeof(T) =3D=3D const)) int a; else string a; } const S!(int) one; S!(const int) two; pragma(msg, typeof(one.a)); // string pragma(msg, typeof(two.a)); // int --MvFDN3d2B4TOF1p20oWssvIM6KtBXMW9o--
Oct 16 2016
On 16.10.2016 14:18, Dicebot wrote:This issue has been discussed before in context of custom containers and AFAIK so far no one was able to come up with even theoretical concept of how it can be possibly addressed.Actually, I did propose a solution before. Just allow annotations on template type parameters (to enable the new implicit upcasts) and check for binary compatibility of the respective template instances during implicit conversion.
Oct 16 2016
protected-headers="v1" From: Dicebot <public dicebot.lv> Newsgroups: d,i,g,i,t,a,l,m,a,r,s,.,D Subject: Re: Advanced const propagation for structs References: <tdsvyuhuamgfibbdszev forum.dlang.org> <ntvr78$lqv$1 digitalmars.com> <nu0t4o$29gm$1 digitalmars.com> In-Reply-To: <nu0t4o$29gm$1 digitalmars.com> --kpG8st2RHWWcsg4MqkVrURmdHgwm5DotQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/17/2016 12:57 AM, Timon Gehr wrote:On 16.10.2016 14:18, Dicebot wrote:ndThis issue has been discussed before in context of custom containers a=ofAFAIK so far no one was able to come up with even theoretical concept =how it can be possibly addressed.=20 Actually, I did propose a solution before. Just allow annotations on template type parameters (to enable the new implicit upcasts) and check=for binary compatibility of the respective template instances during implicit conversion.Can you find a link to that post? I don't remember anything like that. --kpG8st2RHWWcsg4MqkVrURmdHgwm5DotQ--
Oct 16 2016
On 17.10.2016 05:29, Dicebot wrote:On 10/17/2016 12:57 AM, Timon Gehr wrote:forum.dlang.org/post/lkfkel$2avp$1 digitalmars.com forum.dlang.org/post/ljrt6t$2fpc$1 digitalmars.com forum.dlang.org/post/ljt0mc$cto$1 digitalmars.comOn 16.10.2016 14:18, Dicebot wrote:Can you find a link to that post? I don't remember anything like that.This issue has been discussed before in context of custom containers and AFAIK so far no one was able to come up with even theoretical concept of how it can be possibly addressed.Actually, I did propose a solution before. Just allow annotations on template type parameters (to enable the new implicit upcasts) and check for binary compatibility of the respective template instances during implicit conversion.
Oct 17 2016
On Sunday, 16 October 2016 at 08:36:17 UTC, Ilya Yaroshenko wrote:Hi, Extern precompiled Mir GLAS requires additional API changes. Reduced example: ```d struct S(T) { size_t len; T ptr; } auto foo(S!(const(double)*) sl) { } S!(double*) a; const S!(double*) b; foo(a); // fails foo(b); // fails ``` https://issues.dlang.org/show_bug.cgi?id=16616Is there a way to say "the constness (and/or immutability) of this type is dependent on the type of a template parameter". i.e. signal that const A!B is interchangeable with A!(const B) and const A!(const B)? If not does it make sense to add this?
Oct 16 2016
On Sunday, 16 October 2016 at 13:17:09 UTC, Nicholas Wilson wrote:On Sunday, 16 October 2016 at 08:36:17 UTC, Ilya Yaroshenko wrote:A workaround was found https://github.com/dlang/phobos/pull/4869Hi, Extern precompiled Mir GLAS requires additional API changes. Reduced example: ```d struct S(T) { size_t len; T ptr; } auto foo(S!(const(double)*) sl) { } S!(double*) a; const S!(double*) b; foo(a); // fails foo(b); // fails ``` https://issues.dlang.org/show_bug.cgi?id=16616Is there a way to say "the constness (and/or immutability) of this type is dependent on the type of a template parameter". i.e. signal that const A!B is interchangeable with A!(const B) and const A!(const B)? If not does it make sense to add this?
Oct 16 2016