www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Method Template Syntax

reply "John C" <johnch_atms hotmail.com> writes:
Is there a technical reason why a parameterised method needs to be embedded 
in a template scope? I'd prefer not to have to retype the method name:

    template myMethod(T) {
        void myMethod(T param) {

Why not allow us to drop the template name and braces when there's just a 
single method in the scope, similar to the C++ syntax:

    template(T) void myMethod(T param) {

This makes code easier to read as it's less cluttered, and it shouldn't be 
difficult to parse.

For templates with multiple members or members that are not methods, the 
existing syntax would apply only. 
Aug 13 2005
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"John C" <johnch_atms hotmail.com> wrote in message 
news:ddkd3v$2ksg$1 digitaldaemon.com...

I totally agree with you, especially since we already have a "shortcut" 
syntax for template classes. 
Aug 13 2005