digitalmars.D.bugs - [Issue 1100] New: Alias parameters don't accept primitive types.
- d-bugmail puremagic.com (36/36) Apr 05 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1100
- d-bugmail puremagic.com (11/11) Apr 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1100
- d-bugmail puremagic.com (14/14) Apr 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1100
- d-bugmail puremagic.com (7/7) Apr 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1100
- d-bugmail puremagic.com (10/15) Nov 09 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1100
http://d.puremagic.com/issues/show_bug.cgi?id=1100
Summary: Alias parameters don't accept primitive types.
Product: D
Version: 1.010
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: reiner.pope gmail.com
template MyAlias(alias A)
{
alias A MyAlias;
}
void main()
{
alias MyAlias!(int) Myint; // This line fails:
// template instance MyAlias!(int) does not match any template declaration
}
This disagrees with the spec
(http://www.digitalmars.com/d/template.html#aliasparameters) which says that
alias parameters can be type names -- I would certainly consider 'int' to be a
type name. Furthermore, it's unintuitive because a similar call like this works
fine:
struct Int
{
int x;
}
void main()
{
alias MyAlias!(Int) MyInt;
}
--
Apr 05 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1100
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
I changed "type names" to "typedef names" clarify it. The compiler works as
intended - use a template type parameter to pass an arbitrary type. "int" is a
keyword, not a symbol name.
--
Apr 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1100 I would still argue that this is unintuitive behavior; to me an alias parameter is anything that can be aliased. Allowing all types except primitive types in alias parameters creates a seemingly arbitrary distinction between primitive and user types -- don't we want to decrease these differences as much as possible? I can't think of any realistic use cases for primitive types as alias parameters. However, I also can't for userland types. PS. To be really pedantic, Int could be regarded as a symbol in the following: alias int Int; alias MyAlias!(Int) Int2; // MyAlias from before // The above alias also doesn't work --
Apr 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1100 Added to DStress as http://dstress.kuehne.cn/compile/a/alias_42_A.d http://dstress.kuehne.cn/compile/a/alias_42_B.d http://dstress.kuehne.cn/nocompile/a/alias_42_C.d --
Apr 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1100
spunit262 yahoo.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |spunit262 yahoo.com
Added to DStress as
http://dstress.kuehne.cn/compile/a/alias_42_A.d
http://dstress.kuehne.cn/compile/a/alias_42_B.d
http://dstress.kuehne.cn/nocompile/a/alias_42_C.d
Int isn't defined in C, so even if alias parameters did accept primitive types
(which there isn't *any* reason for not to), it wouldn't compile.
--
Nov 09 2007









d-bugmail puremagic.com 