Hello Tim,

On Sun, 15 Mar 2009 06:27:42 +1300, BCS <n...@anon.com> wrote:

there is no compact form for alias but this

T Foo(T)(T t) { return t; }

is internally identical the the more verbose form:

template Foo(T) { T Foo(T t){ return t; } }

Hi BCS. On this page: http://www.digitalmars.com/d/1.0/template.html
scroll down to "Implicit Template Properties" and it says:

"If a template has exactly one member in it, and the name of that
member  is the same as the template name, that member is assumed to be
referred to  in a template instantiation".

I think Andrei Alexandrescu was actually looking a catchy name for
this.  You don't have to specify the templates only property, you use
the  template directly. So its a technique used to make your code less
verbose.


Yes, I known that. I was answering the question you asked about what is verbose about the usage Andrei posted. I was pointing out that if you consider not the feature he was asking about but the form he used, then verbose is a good description. If the example is converted to a function example, as I illustrated, then this becomes even more clear as the form Andrei used is indeed more verbose than the other option.

The person who suggested "verbose" as a good name is not totally off base as often, even with functions, you end up needing to switch to the more verbose form to allow static asserts or static ifs around the function.


Reply via email to