Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 18, 2010 [Issue 4675] New: Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4675 Summary: Eponymous Template should hide internal names Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2010-08-18 13:19:16 PDT --- Code: import std.stdio; void main() { } template isNumeric(T) { enum bool test1 = is(T : long); // should be hidden enum bool test2 = is(T : real); // should be hidden enum bool isNumeric = test1 || test2; } unittest { static assert(isNumeric!(int).test1); // should be an error writeln(isNumeric!(int).test1); // should be an error, but writes true writeln(isNumeric!(int).test2); // should be an error, but writes true } According to TDPL, calling isNumeric!(T) is rewritten by the compiler to isNumeric!(T).isNumeric, therefore hiding access to any other names. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 21, 2010 [Issue 4675] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 Torarin <torarin@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |torarin@gmail.com --- Comment #1 from Torarin <torarin@gmail.com> 2010-08-20 17:26:26 PDT --- I ran into trouble with this example as well, but this time because what should work, doesn't: import std.stdio; template isNumeric(T) { enum bool test1 = is(T : long); enum bool test2 = is(T : real); enum bool isNumeric = test1 || test2; } void main() { bool a = isNumeric!int; } Fails with: test.d(12): Error: expression isNumeric!(int) is void and has no value. I was surprised to find that the language reference actually contradicts TDPL here: "Implicit Template Properties If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation." (In reply to comment #0) > > According to TDPL, calling isNumeric!(T) is rewritten by the compiler to > isNumeric!(T).isNumeric, therefore hiding access to any other names. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 21, 2010 [Issue 4675] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2010-08-20 17:35:05 PDT --- There are more cases of contradiction, but I think this has to do with some of the spec not being updated. In other cases some features are simply not yet implemented.. My guess is that this feature should be implemented like it states in TDPL. Otherwise for any non-trivial templates you would have to write code like: isNumeric!(int).isNumeric -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 21, 2010 [Issue 4675] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 --- Comment #3 from Torarin <torarin@gmail.com> 2010-08-20 17:54:25 PDT --- Yes. std.traits deals with it by doing private template hasRawAliasing(T...) { enum hasRawAliasing = hasRawPointerImpl!(RepresentationTypeTuple!(T)).result; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 27, 2010 [Issue 4675] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #4 from bearophile_hugs@eml.cc 2010-08-27 16:26:55 PDT --- Time ago some people have proposed to allow "private" for that purpose: template isNumeric(T) { private enum bool test1 = is(T : long); private enum bool test2 = is(T : real); enum bool isNumeric = test1 || test2; } This is good because the person that reads the code doesn't need to remember the rule that test1 and test2 become invisible if isNumeric is defined inside isNumeric(). So I think this is a more tidy solution to the problem. On the other hand you want all names to be private but the one that is eponymous, so the solution in TDPL is shorter (and probably acceptable still). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 31, 2011 [Issue 4675] [tdpl] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2011-12-31 05:39:13 PST --- https://github.com/D-Programming-Language/dmd/pull/590 Eponymous member always hides other members (do not consider access attributes). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 16, 2012 [Issue 4675] [tdpl] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2012-01-15 19:17:09 PST --- https://github.com/D-Programming-Language/dmd/commit/91facb7b443bb61793b045fab9715be633f1aa99 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 22, 2012 [Issue 4675] [tdpl] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 --- Comment #7 from dawg@dawgfoto.de 2012-01-22 01:37:35 PST --- *** Issue 2640 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: ------- |
January 24, 2012 [Issue 4675] [tdpl] Eponymous Template should hide internal names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=4675 Denis <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |verylonglogin.reg@gmail.com --- Comment #8 from Denis <verylonglogin.reg@gmail.com> 2012-01-25 02:06:38 MSK --- Still doesn't work in most real-life (Phobos) cases. Filled Issue 7363. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation