Template functions, can we make it more simple?
monarch_dodra
monarchdodra at gmail.com
Sat Aug 3 00:16:35 PDT 2013
On Saturday, 3 August 2013 at 00:51:21 UTC, F i L wrote:
> I've brought this up on here awhile ago, and many people seemed
> to be against it. Which I don't agree with, since the
> ambiguities it creates are easily addressed (from a design
> perspective at least) and only exist so that C-style code is
> usable within D. It could work like:
>
> auto func(a, b) // auto func(A, B)(A a, B b)
> auto func(int a, b) // auto func(B)(int a, B b)
> auto func(int ?) // C-style: auto func(int)
Regardless of the existing merits, that would be a (massive)
breaking change, and as mentioned, it brings nothing we couldn't
do before...
> Or...
>
> auto func(auto a, auto b) // like C++14
>
> I mean honestly, who's hand-writing a bunch of functions with
> nameless params in real D code? Sure it's used for linking to
> C, which is semi-common, but I think having the much cleaner
> syntax available to "actual" D code makes more sense that not
> having it solely for linking-to-C-in-familiar-C-style reasons.
Anytime I write the body of a function that doesn't use one of
its args, I keep the arg name empty. This implicitly documents
that the arg is unused. Many people do this in C++ too, since
msvc will flag you for not doing it anyways. So your answer your
question: "who's hand-writing a bunch of functions with nameless
params in real D code": Lot's of people, including in Phobos.
More information about the Digitalmars-d
mailing list