Re: Help needed to learn templates

2022-03-20 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 19 March 2022 at 22:31:19 UTC, Stanislav Blinov wrote: It is appearing not in the `static if`, but in the `is` expression, which I described further in the rest of my first reply. Sorry if that wasn't clear. No, it was my mistake, I missed it. The other template syntax - `temp

Re: Help needed to learn templates

2022-03-19 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 19 March 2022 at 13:38:42 UTC, Vinod K Chandran wrote: On Saturday, 19 March 2022 at 11:47:53 UTC, Stanislav Blinov wrote: No. First of all Thanks for the reply. The answer "No" is a wonder to me. Because, from my point of view, `U` is coming from nowhere. My understanding is, w

Re: Help needed to learn templates

2022-03-19 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 19 March 2022 at 16:08:33 UTC, Ali Çehreli wrote: Here is the clickable url: http://ddili.org/ders/d.en/is_expr.html I just read it again and I still like what I wrote there. :) (Usually it is the other way around.) Ali Thanks. Let me read that chapter.

Re: Help needed to learn templates

2022-03-19 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 19 March 2022 at 15:58:25 UTC, Ali Çehreli wrote: I wrote a chapter about the is expression but it's still mysterious to me. :) ddili.org/ders/d.en/is_expr.html Thanks for the reply. I think I choose the wrong book. I knew about your book but I thought this one is specially

Re: Help needed to learn templates

2022-03-19 Thread Ali Çehreli via Digitalmars-d-learn
On 3/19/22 08:58, Ali Çehreli wrote: > I wrote a chapter about the is expression but it's still mysterious to > me. :) > >ddili.org/ders/d.en/is_expr.html Here is the clickable url: http://ddili.org/ders/d.en/is_expr.html I just read it again and I still like what I wrote there. :) (Usua

Re: Help needed to learn templates

2022-03-19 Thread Ali Çehreli via Digitalmars-d-learn
On 3/19/22 06:38, Vinod K Chandran wrote: > On Saturday, 19 March 2022 at 11:47:53 UTC, Stanislav Blinov wrote: >> >> No. >> > First of all Thanks for the reply. The answer "No" is a wonder to me. I wrote a chapter about the is expression but it's still mysterious to me. :) ddili.org/ders/d.

Re: Help needed to learn templates

2022-03-19 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 19 March 2022 at 08:49:02 UTC, Salih Dincer wrote: Thanks for the reply. You explained the idea very well and it's easy to understand for a novice.

Re: Help needed to learn templates

2022-03-19 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 19 March 2022 at 11:47:53 UTC, Stanislav Blinov wrote: No. First of all Thanks for the reply. The answer "No" is a wonder to me. Because, from my point of view, `U` is coming from nowhere. My understanding is, we can use any parameter of a template inside the template. So in thi

Re: Help needed to learn templates

2022-03-19 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 19 March 2022 at 05:54:26 UTC, Vinod K Chandran wrote: Question 1 - `U` is appearing in the first static if statement. But we had to write `U` on the template line, right? Like - `template rank(T, U)` No. Question 2 - The statif if test is - `T t == U[ ]` What does that mean ?

Re: Help needed to learn templates

2022-03-19 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 19 March 2022 at 05:54:26 UTC, Vinod K Chandran wrote: Question 1 - `U` is appearing in the first static if statement. But we had to write `U` on the template line, right? Like - `template rank(T, U)` Question 2 - The statif if test is - `T t == U[ ]` What does that mean ? Question

Help needed to learn templates

2022-03-18 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am trying to learn D templates with Philippe Sigaud's "D Templates: A Tutorial". So far so good. I have completed first 19 pages and in the 20th page, I found an obstacle. This is the code. ```d module rank1; template rank(T) { static if (is(T t == U[], U)) // is T an array of U,