On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote:
but I'm still stuck. Do you have a down-to-earth example for
beginners to understand this concept?
I often go back to this post when writing templates:
https://dlang.org/blog/2020/07/31/the-abcs-of-templates-in-d/
It helped me when
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote:
This is the definition of "filter" function, and I think it
called itself within its definition. I'm guessing how it works?
'''D
template filter(alias predicate)
if (is(typeof(unaryFun!predicate)))
{
/**
Params:
range =
On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote:
On Tuesday, 2 August 2022 at 04:06:30 UTC, frame wrote:
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote:
This is the definition of "filter" function, and I think it
called itself within its definition. I'm guessing how it
On Tuesday, 9 August 2022 at 18:23:04 UTC, Ali Çehreli wrote:
On 8/2/22 05:39, pascal111 wrote:
> I'm still stuck. Do you have a
> down-to-earth example for beginners to understand this
concept?
I will refer to my explanation because down-to-earth has always
been my goal. I hope i succeeded:
On 8/2/22 05:39, pascal111 wrote:
> I'm still stuck. Do you have a
> down-to-earth example for beginners to understand this concept?
I will refer to my explanation because down-to-earth has always been my
goal. I hope i succeeded:
leyts try very rough simlified concept:
template itself - is compile-time program (parameterizable), it
can generate some code for you.
template instantiation (like "calling") with "!" - instruct
compiler to "start this compile-time program here with this
parameters".
On Tuesday, 2 August 2022 at 14:58:52 UTC, pascal111 wrote:
Maybe this helps:
A template can be seen as a static struct too, so you can
access its members with the scope operator "." and if there is
only one member of the same name as the template ifself, the
compiler auto completes it to
On Tuesday, 2 August 2022 at 14:24:50 UTC, frame wrote:
On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote:
Instantiation seems some complicated to me. I read "If a
template contains members whose name is the same as the
template identifier then these members are assumed to be
On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote:
Instantiation seems some complicated to me. I read "If a
template contains members whose name is the same as the
template identifier then these members are assumed to be
referred to in a template instantiation:" in the provided link,
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote:
I think this line needs explanation:
'''D
return FilterResult!(unaryFun!predicate, Range)(range);
'''
Create an object of type `FilterResult!(unaryFun!predicate,
Range)` by passing `range` to its ctor, then return that object.
On Tuesday, 2 August 2022 at 04:06:30 UTC, frame wrote:
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote:
This is the definition of "filter" function, and I think it
called itself within its definition. I'm guessing how it works?
It's a template that defines the function called
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote:
This is the definition of "filter" function, and I think it
called itself within its definition. I'm guessing how it works?
It's a template that defines the function called "Eponymous
Templates":
12 matches
Mail list logo