D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4056 - Template instantiation with bare parameter not documented
Summary: Template instantiation with bare parameter not documented
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL: http://digitalmars.com/d/2.0/template...
Keywords: spec
Depends on:
Blocks:
 
Reported: 2010-04-02 21:24 UTC by Jerry Quinn
Modified: 2014-02-15 02:44 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jerry Quinn 2010-04-02 21:24:02 UTC
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?
Comment 1 Ellery Newcomer 2010-05-24 11:04:48 UTC
(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.
Comment 2 Walter Bright 2010-05-28 10:36:31 UTC
changeset 1564