Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-04-30 Thread Elfstone via Digitalmars-d-learn
module test; struct MatrixImpl(S, size_t M, size_t N) { } template Vector(S, size_t N) { alias Vector = MatrixImpl!(S, 1, N); } @nogc S dot1(S, size_t N)(in Vector!(S, N) lhs, in Vector!(S, N) rhs) { return 0; } @nogc S dot2

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-04-30 Thread Tejas via Digitalmars-d-learn
On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: module test; struct MatrixImpl(S, size_t M, size_t N) { } [...] AFAICT, I'm afraid you'll have to stick to `dot2` 🙁 This DIP I believe does what you want but... It wasn't looked upon favorably... https://github.com/dl

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Elfstone via Digitalmars-d-learn
On Sunday, 1 May 2022 at 06:42:26 UTC, Tejas wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: module test; struct MatrixImpl(S, size_t M, size_t N) { } [...] AFAICT, I'm afraid you'll have to stick to `dot2` 🙁 This DIP I believe does what you want but... It was

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread JG via Digitalmars-d-learn
On Sunday, 1 May 2022 at 07:59:57 UTC, Elfstone wrote: On Sunday, 1 May 2022 at 06:42:26 UTC, Tejas wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: module test; struct MatrixImpl(S, size_t M, size_t N) { } [...] AFAICT, I'm afraid you'll have to stick to `dot2`

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread JG via Digitalmars-d-learn
On Sunday, 1 May 2022 at 11:34:49 UTC, JG wrote: On Sunday, 1 May 2022 at 07:59:57 UTC, Elfstone wrote: On Sunday, 1 May 2022 at 06:42:26 UTC, Tejas wrote: [...] Thanks a lot! So this really is a D "feature". The current behaviour is so broken. It makes no sense, for a language user at least

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Elfstone via Digitalmars-d-learn
On Sunday, 1 May 2022 at 11:37:28 UTC, JG wrote: On Sunday, 1 May 2022 at 11:34:49 UTC, JG wrote: [...] The static assert isn't needed. ```d enum isVector(V) = is(V==MatrixImpl!(S,1,N),S,size_t N); @nogc auto dot1(V)(in V lhs, in V rhs) if(isVector!V) { static if(is(V==MatrixImpl!(S,1,

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 1 May 2022 at 12:39:08 UTC, Elfstone wrote: Great, I'm using the constraint, until it's fixed. Will it be fixed though? The DIP that Tejas linked is from 2020!!! The DIP was postponed. I can contact the author to see if he intends to pick it up again. If not, anyone interested can

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Elfstone via Digitalmars-d-learn
On Sunday, 1 May 2022 at 14:14:59 UTC, Mike Parker wrote: On Sunday, 1 May 2022 at 12:39:08 UTC, Elfstone wrote: Great, I'm using the constraint, until it's fixed. Will it be fixed though? The DIP that Tejas linked is from 2020!!! The DIP was postponed. I can contact the author to see if he

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 2 May 2022 at 00:54:40 UTC, Elfstone wrote: Thanks. This breaks a lot of things. I don't know the reason behind the postponing, but who would expect one can't declare a parameter with an alias if it's a template?! Speaking of inconsistency. At the bottom of the DIP you can find a

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Loara via Digitalmars-d-learn
On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: module test; struct MatrixImpl(S, size_t M, size_t N) { } template Vector(S, size_t N) { alias Vector = MatrixImpl!(S, 1, N); } @nogc S dot1(S, size_t N)(in Vector!(S, N) lhs, in Vector!(S, N) r

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread JG via Digitalmars-d-learn
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: [...] Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code: ```d template

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code: ```d template MyAlias(T){ alias MyAlias = int; } T simp(T)(MyAl

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Ali Çehreli via Digitalmars-d-learn
On 5/2/22 12:17, Stanislav Blinov wrote: > On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: > >> Template deduction for aliased function parameter is a very tricky >> argument and it's not so simple to handle in certain cases. Consider >> for example this code: >> >> ```d >> template MyAlia

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread ag0aep6g via Digitalmars-d-learn
On 02.05.22 21:17, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: [...] ```d     template MyAlias(T){   alias MyAlias = int;     }     T simp(T)(MyAlias!T val){   return T.init;     }     int main(){   simp(3);//Impossible to deduce T Why? That's the

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 2 May 2022 at 20:08:48 UTC, Ali Çehreli wrote: On 5/2/22 12:17, Stanislav Blinov wrote: > On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: > >> Template deduction for aliased function parameter is a very tricky >> argument and it's not so simple to handle in certain cases. Consider

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote: On 02.05.22 21:17, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: [...] ```d     template MyAlias(T){   alias MyAlias = int;     }     T simp(T)(MyAlias!T val){   return T.init;     }     int main(){

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread JG via Digitalmars-d-learn
On Monday, 2 May 2022 at 19:17:19 UTC, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code: ```d template

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread ag0aep6g via Digitalmars-d-learn
On 02.05.22 22:47, Stanislav Blinov wrote: On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote: On 02.05.22 21:17, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: [...] ```d     template MyAlias(T){   alias MyAlias = int;     }     T simp(T)(MyAlias!T val){

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Tejas via Digitalmars-d-learn
On Monday, 2 May 2022 at 22:01:51 UTC, ag0aep6g wrote: On 02.05.22 22:47, Stanislav Blinov wrote: On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote: On 02.05.22 21:17, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: [...] ```d     template MyAlias(T){   al

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Tejas via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 00:38:34 UTC, Tejas wrote: On Monday, 2 May 2022 at 22:01:51 UTC, ag0aep6g wrote: On 02.05.22 22:47, Stanislav Blinov wrote: On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote: On 02.05.22 21:17, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Elfstone via Digitalmars-d-learn
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: [...] Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code: ```d template

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 06:20:53 UTC, Elfstone wrote: Yeah, I understand some cases are impossible, and to be avoided. I believe your example is also impossible in C++, but it's better the compiler do its job when it's totally possible - needless to say, C++ compilers can deduce my _dot_. Con

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Loara via Digitalmars-d-learn
On Monday, 2 May 2022 at 17:21:53 UTC, JG wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: [...] Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Co

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Loara via Digitalmars-d-learn
On Monday, 2 May 2022 at 19:17:19 UTC, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code: ```d template

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Ali Çehreli via Digitalmars-d-learn
On 5/2/22 13:36, Stanislav Blinov wrote: >> That's fine because D does not promise to solve such problems. It >> follows simple deduction rules. > > Words, dear guru. Words have a meaning. It is very possible to deduce > here (note the premise). D just isn't trying. That's what I said. Yo

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 15:41:08 UTC, Ali Çehreli wrote: We also have NP-completeness. Ok, so C++ has similar limitations when you have a template with an unknown parameter in a function parameter, but is this because it would be NPC? Also, do we know that it cannot be resolved for the typ

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-04 Thread bauss via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 07:11:48 UTC, Ola Fosheim Grøstad wrote: As you see, someone will have to write a DIP to fix this bug, as the language authors don't consider it a bug, but an enhancement. I don't believe those two words are mutually exclusive. It can be a bug __and__ an enhancem

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-04 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 10:15:18 UTC, bauss wrote: It can be a bug __and__ an enhancement. Alright, but we need a DIP to get the enhancement which can be in. :-) I don't think anything will improve without one. I would assume that C++ template resolution is O(N), so I am not as pessimis