Thread overview
[Issue 4056] New: Template instantiation with bare parameter not documented
Apr 03, 2010
Jerry Quinn
May 24, 2010
Ellery Newcomer
May 28, 2010
Walter Bright
April 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4056

           Summary: Template instantiation with bare parameter not
                    documented
           Product: D
           Version: 2.041
          Platform: All
               URL: http://digitalmars.com/d/2.0/template.html
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: nobody@puremagic.com
        ReportedBy: jlquinn@optonline.net


--- Comment #0 from Jerry Quinn <jlquinn@optonline.net> 2010-04-02 21:24:02 PDT ---
I've recently seen people using template instances like:

mytemplate!int var;

The docs don't say anything about this form, nor do the release notes for that matter.  Either it's a bug (I assume not) or the spec needs to document it.

I assume this form is only good for single template parameters.  Are there other limits on what parameters can be used in this way?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 24, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4056


Ellery Newcomer <ellery-newcomer@utulsa.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ellery-newcomer@utulsa.edu


--- Comment #1 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2010-05-24 11:04:48 PDT ---
(In reply to comment #0)
> I've recently seen people using template instances like:
> 
> mytemplate!int var;
> 
> The docs don't say anything about this form, nor do the release notes for that matter.  Either it's a bug (I assume not) or the spec needs to document it.
> 
> I assume this form is only good for single template parameters.  Are there other limits on what parameters can be used in this way?

in template.html, modify

TemplateInstance:
    TemplateIdentifier !( TemplateArgumentList )

to

TemplateInstance:
    TemplateIdentifier !( TemplateArgumentList )
    TemplateIdentifier ! Identifier
    TemplateIdentifier ! BuiltinBasicType
        TemplateIdentifier ! Literal

Literal:
    null
    true
    false
    __FILE__
    __LINE__
    NumericLiteral
    CharacterLiteral
    StringLiterals

but then in declarations.html you'd have to split up BasicType a bit.

And yes, this can't work for multiple parameters because the commas would cause ambiguity with Expression. Same for identifier chains:

T!A.B == T!(A).B or T!(A.B) ?

and extended types:

T!i[] == T!(i)[] or T!(i[]) ?

etc.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4056


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2010-05-28 10:36:31 PDT ---
changeset 1564

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------