www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1012] New: type templates don't support default arguments

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

           Summary: type templates don't support default arguments
           Product: D
           Version: 1.007
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thomas-dloop kuehne.cn













test.d(9): class test.Bar(T = int) is used as a type
test.d(9): Error: new can only create structs, dynamic arrays or class objects, 
not void's


-- 
Feb 28 2007
next sibling parent reply Don Clugston <dac nospam.com.au> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=1012
 
            Summary: type templates don't support default arguments
            Product: D
            Version: 1.007
           Platform: PC
         OS/Version: All
             Status: NEW
           Severity: normal
           Priority: P3
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: thomas-dloop kuehne.cn
 
 










 
 test.d(9): class test.Bar(T = int) is used as a type
 test.d(9): Error: new can only create structs, dynamic arrays or class
objects, 
 not void's
 
 
Are you allowed to leave out the !() in class template instantations? I'd expect to have to write auto b = new Bar!()(); or at least auto b = new Bar!();
Mar 01 2007
parent Sean Kelly <sean f4.ca> writes:
Don Clugston wrote:
 Are you allowed to leave out the !() in class template instantations?
No, but I think you perhaps should be allowed. I posted as much here asking for comments, but the thread got no replies: http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=48672
Mar 01 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1012


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement





AIUI this isn't supposed to work.  If we allowed such implicit template
instantiation everywhere, it would create ambiguities (alias declarations come
to mind).  That's why, at the moment, it's explicitly allowed in some contexts
where it's unambiguous, such as IFTI and (to some degree) mixins.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1012




PDT ---
Created an attachment (id=466)
convert TypeIdentifer refering to TemplateDeclaration to TypeInstance

I don't expect any additional ambiguities, because the template types are in
the same namespace as all other identifers anyway (apart from version and debug
identifiers). 
This patch against 2.032 converts a TypeIdentifier (as created by the parser)
into a TypeInstance if name lookup revealed that it is actually a template.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 30 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1012


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |leo.dahlmann gmail.com



*** Issue 1328 has been marked as a duplicate of this issue. ***

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


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



D2 pull:
https://github.com/D-Programming-Language/dmd/pull/1295

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



10:39:26 PST ---
I have severe misgivings about this.

C has had problems with implicitly taking the address of a function. D has had
a number of problems with implicitly calling a function (the  property thing).

It's just ambiguous in many cases, and leads to trouble, trouble, trouble.

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


Jonathan M Davis <jmdavisProg gmx.com> changed:

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



PST ---
 I have severe misgivings about this.
I concur. It seems like it just begging for trouble when providing minimal gain. Not to mention that it would harm code readability in many cases, which will therefore harm code maintainability. example here would compile, but that would be restricted specifically to constructors. Making it so that templates in general can be instantiated without !() if they don't need any arguments is a bad idea IHMO. And I think that this post on the newsgroup is a good example of why this is a bad idea: http://forum.dlang.org/post/vmipipnhyiilketbygbw forum.dlang.org -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1012


Jakob Ovrum <jakobovrum gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakobovrum gmail.com



---


It's not possible in the general case. http://stackoverflow.com/questions/13151072/ It might still be an attractive feature to have for specific, common cases, but it would either have to be defined as a "compiler's best effort" thing, which hurts portability, or defined to only work for a select few specific cases. The latter is what's currently done for IFTI, but the rules are intuitive, especially thanks to eponymous templates. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2012