'!' and naming conventions
Brad Anderson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 18 14:02:34 PDT 2014
On Wednesday, 18 June 2014 at 20:55:36 UTC, cym13 wrote:
> Hello,
>
> I see a lot of functions and other stuff with a '!' in the name
> such as 'bitfields!' or 'ctRegex!'. What does it mean exactly?
> In
> scheme, we use such a convention to warn that a function is not
> pure, but I don't see the point of using it that way in D as
> there are other way to express it.
>
> Moreover, I'm looking for a style guide of D, something like the
> PEP8 for python. Is there anything like that?
>
> Thanks!
The ! specifies that a template argument list follows.
auto fun(T)(T a, T b) { return a * b; }
void main()
{
// fun can be called using several different ways:
fun!(int)(1, 2); // Specifying the template arguments
fun!int(1, 2); // If there is only one template argument the
// parens can be omitted
fun(1, 2); // IFTI can be used to figure out the types
for you
}
There is a style guide on the website:
http://dlang.org/dstyle.html
Personally I just consider this a Phobos contributor style guide
and not like a PEP8 style guideline.
More information about the Digitalmars-d-learn
mailing list