digitalmars.D.bugs - [Issue 2152] New: Parentheses usage inconsistency.
- d-bugmail puremagic.com (28/28) Jun 18 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2152
- d-bugmail puremagic.com (51/51) Jun 18 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2152
- d-bugmail puremagic.com (14/14) Aug 04 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2152
- d-bugmail puremagic.com (11/11) Jan 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2152
http://d.puremagic.com/issues/show_bug.cgi?id=2152 Summary: Parentheses usage inconsistency. Product: D Version: 1.027 Platform: PC OS/Version: Windows Status: NEW Keywords: rejects-valid, spec Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: gim913 gmail.com I'm not sure if this is a bug, and I don't know if this can be fixed. I was playing with h3r3tic's Singleton template. I have overloaded opIndex, and opIndexAssign in a class, and made the class wrapped the class with singleton (it doesn't have a meaning probably any function returning class will do the effect). When getting value, I can skip brackets after function call, like: foo = bar["something"]; but when setting value (calling opIndexAssign) I am forced to use brackets around function call, otherwise I get compiler error: bar()["something"] = foo; Please take a look at following two testcases: http://ncu.codepad.org/7pBqIx25 http://ncu.codepad.org/JjGFdmsO Sorry, if this issue is a duplicate. --
Jun 18 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2152 (Added to issues to make sure the code is not lost by codepad) first example: /* Michal 'GiM' Spadlinski */ import tango.io.Stdout; T Singleton(T)() { static T singletonInstance; if (singletonInstance is null) { synchronized (T.classinfo) { if (singletonInstance is null) { singletonInstance = new T; static if (is (typeof (singletonInstance.initialize))) { singletonInstance.initialize(); } } } } return singletonInstance; } class Klasa { int opIndex(char[] ind) { Stdout ("oh hai! : ", ind).newline; return 666; } int opIndexAssign(int val, char[] ind) { Stdout ("oh hai! : ") (ind) (" = ") (val).newline; return 0; } } alias Singleton!(Klasa) klasa; void main() { auto temp = klasa["blah"]; Stdout ("in main: ") (temp).newline; klasa["blah"] = temp; //klasa()["blah"] = temp; } Error: Line 41: Error: Singleton()["blah"] is not an lvalue second example switches comments at line 41 & 42 Output: oh hai! : , blah in main: 666 oh hai! : blah = 666 --
Jun 18 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2152 Rob Jacques <sandford jhu.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sandford jhu.edu This seems releated to Issue 2409. Also another use case: void delegate(int) func(); void main() { func(1); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 04 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2152 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|spec | CC| |bugzilla digitalmars.com 20:53:50 PST --- Not a spec issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 21 2012