www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D lang newbie ..what does syntax func_name !() represent ??

reply Andy Balba <pwplus7 gmail.com> writes:
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
Jul 24 2020
next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
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++.
Jul 24 2020
parent Andy Balba <pwplus7 gmail.com> writes:
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
Jul 24 2020
prev sibling parent reply Mike Parker <aldacron gmail.com> writes:
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
Jul 24 2020
parent aberba <karabutaworld gmail.com> writes:
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.
Jul 25 2020