Thread overview
D lang newbie ..what does syntax func_name !() represent ??
Jul 25, 2020
Andy Balba
Jul 25, 2020
Adam D. Ruppe
Jul 25, 2020
Andy Balba
Jul 25, 2020
Mike Parker
Jul 25, 2020
aberba
July 25, 2020
Hello forum
 I'm a long-time C/C++ coder who recently completed the D lang on-line tour and want to improve my D lang savy.

I keep running into statements like  `func_name!()`
and cant figure out what !() could possibly mean .

Pz help, it's driving me nuts


July 25, 2020
On Saturday, 25 July 2020 at 00:36:19 UTC, Andy Balba wrote:
> I keep running into statements like  `func_name!()`
> and cant figure out what !() could possibly mean .

That's a template instance, like foo<int> in C++.

Though D can pass a lot more than just types to its templates so you might see like foo!"bar" too, but it is the same idea - passing that string as a template argument to foo.

BTW if there is just one simple argument, you can leave the parentehsis out like I did there.

to!int

is the same as

to!(int)

which is like

to<int>

in C++.
July 25, 2020
On Saturday, 25 July 2020 at 00:36:19 UTC, Andy Balba wrote:
> Hello forum
>  I'm a long-time C/C++ coder who recently completed the D lang on-line tour and want to improve my D lang savy.
>
> I keep running into statements like  `func_name!()`
> and cant figure out what !() could possibly mean .
>
> Pz help, it's driving me nuts

https://dlang.org/spec/template.html
July 25, 2020
On Saturday, 25 July 2020 at 00:42:04 UTC, Adam D. Ruppe wrote:
> On Saturday, 25 July 2020 at 00:36:19 UTC, Andy Balba wrote:
>> I keep running into statements like  `func_name!()`
>> and cant figure out what !() could possibly mean .
>
> That's a template instance, like foo<int> in C++.
>
> Though D can pass a lot more than just types to its templates so you might see like foo!"bar" too, but it is the same idea - passing that string as a template argument to foo.
>
> BTW if there is just one simple argument, you can leave the parentehsis out like I did there.

many thanks
July 25, 2020
On Saturday, 25 July 2020 at 01:23:18 UTC, Mike Parker wrote:
> On Saturday, 25 July 2020 at 00:36:19 UTC, Andy Balba wrote:
>> Hello forum
>>  I'm a long-time C/C++ coder who recently completed the D lang on-line tour and want to improve my D lang savy.
>>
>> I keep running into statements like  `func_name!()`
>> and cant figure out what !() could possibly mean .
>>
>> Pz help, it's driving me nuts
>
> https://dlang.org/spec/template.html

Watched a video and they were also struggling to figure out what ! means as it's used right at the beginning.

Could we highlight what the "!" mean? ...kind of like how Adam explained it?

Especially when they've at that point not got to the templates section yet.