Exclamation symbol "!" within functions syntax

pascal111 judas.the.messiah.111 at gmail.com
Mon Aug 1 13:23:05 UTC 2022

On Monday, 1 August 2022 at 12:58:27 UTC, Paul Backus wrote:
> On Monday, 1 August 2022 at 11:35:25 UTC, pascal111 wrote:
>> I noticed that filter is using the concept of templates but 
>> this time it's with a lambda function, not with a data type, 
>> how can we explain this? isn't supposed to use a data type 
>> after the exclamation mark: "auto r = chain(a, b).filter!(a => 
>> a > 0);"
>> https://dlang.org/phobos/std_algorithm_iteration.html#.filter.filter
> If you look at the documentation for the filter template [1], 
> you will notice that the "predicate" parameter is marked with 
> the keyword "alias":
>     template filter(alias predicate)
> Alias template parameters are special. They can accept not only 
> types, but also values, names of variables, and even things 
> like modules and packages as arguments. You can read more about 
> them in the "More Templates" chapter of Ali's book [2], and in 
> the official D language specification [3].
> [1] 
> https://dlang.org/phobos/std_algorithm_iteration.html#.filter
> [2] 
> http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.alias,%20template%20parameter
> [3] https://dlang.org/spec/template.html#aliasparameters

Ok! I'll read about that from the suggested sources, but with 
respect to Ali's book, he should put "More Templates" after the 
chapter of "templates", but he put "Pragmas" instead of that 

More information about the Digitalmars-d-learn mailing list