www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8364] New: Allow exclamation mark in template definition

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8364

           Summary: Allow exclamation mark in template definition
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: qwertie256 gmail.com



PDT ---
The syntax of templates should be similar at the definition as it is at the
call site:

T sum!(T,R)(R range) if (isInputRange!R...) { ... }

Of course, the existing syntax must be kept too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8364


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc




 The syntax of templates should be similar at the definition as it is at the
 call site:
Why? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 09 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8364


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PDT ---
Of what value is that? The current situation is wonderfully unambiguous.

This proposal would make the parser's life harder and would probably make it so
that the grammar could no longer be context free (which would be very bad). And
from the perspective of the programmer (not just the compiler), it's _useful_
to be able to tell the difference between a template and a template
instantiation at a glance.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8364


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr gmx.ch




 Of what value is that? The current situation is wonderfully unambiguous.
 
True.
 This proposal would make the parser's life harder
Not really. Having this as the only template declaration syntax would even make the parser's life easier. (and if both were legal, parsing the kind that has the '!' would be slighly more efficient.)
 and would probably make it so that the grammar could no longer be context free 
This is not the case. The grammar would stay context free.
 (which would be very bad).
 And from the perspective of the programmer (not just the compiler), it's 
 _useful_ to be able to tell the difference between a template and a template
 instantiation at a glance.
The proposal does not put this ability in danger. Anyway, I don't prefer either scheme and in my opinion it is fine to either leave the template declaration grammar as it is, or to change it to always require '!'. The latter is not going to happen though. (I remember that when I wrote my very first function template in D, I used the proposed syntax and was confused that it didn't work.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 09 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8364




PDT ---
 Why?
Because one syntax is easier to learn than two. Timon said "when I wrote my very first function template in D, I used the proposed syntax and was confused that it didn't work", and that makes two of us (well, I quickly realized why the compiler complained, but my first instinct is to use !, and it feels really dumb that I can't). Plus, the parser might be able to handle ! more quickly, since it will know to expect "TemplateParameterList" instead of "Parameters". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 10 2012