Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 25, 2020 D lang newbie ..what does syntax func_name !() represent ?? | ||||
---|---|---|---|---|
| ||||
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 Re: D lang newbie ..what does syntax func_name !() represent ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Balba | 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 Re: D lang newbie ..what does syntax func_name !() represent ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Balba | 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 Re: D lang newbie ..what does syntax func_name !() represent ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 Re: D lang newbie ..what does syntax func_name !() represent ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | 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.
|
Copyright © 1999-2021 by the D Language Foundation