[Issue 8640] New: Template struct/class member functions should compile conditionally
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 11 06:15:20 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8640
Summary: Template struct/class member functions should compile
conditionally
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2012-09-11 06:15:40 PDT ---
>From the conversation here:
http://forum.dlang.org/thread/hgmloyopgeoxjzhfuyub@forum.dlang.org
Not entirely sure if this is a bug, or an enhancement request (The answer I got
was "In this case I think D is working as designed")
Basically:
-------
struct S
{
const int i;
}
struct C(T)
{
private T val;
@property T front()
{return val;}
@property void front(T value)
{val = value;} //HERE
}
void main()
{
C!S test;
}
--------
This creates a compilation error at "here". Problem: The non-compiling function
was never called.
I think that member functions of template structs/classes should be compiled
conditionally only when they are called.
Doing otherwise really burdens the developer with making implementation
conditions for *all* his functions.
Suggest that member functions only be compiled and validated when called.
This *should* be possible, because doing this bypasses the problem:
--------
struct C(T)
{
private T val;
@property T front()() //Template specialization
{return val;}
@property void front()(T value) //Template specialization
{val = value;}
}
--------
//Technically, the first specialization is not needed, but there is currently a
limitation regarding template/non-template overloads.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list