Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 18, 2008 [Issue 2152] New: Parentheses usage inconsistency. | ||||
---|---|---|---|---|
| ||||
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. -- |
June 18, 2008 [Issue 2152] Parentheses usage inconsistency. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2152 ------- Comment #1 from shro8822@vandals.uidaho.edu 2008-06-18 11:53 ------- (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 -- |
August 04, 2009 [Issue 2152] Parentheses usage inconsistency. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2152 Rob Jacques <sandford@jhu.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sandford@jhu.edu --- Comment #2 from Rob Jacques <sandford@jhu.edu> 2009-08-04 05:48:49 PDT --- 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: ------- |
January 22, 2012 [Issue 2152] Parentheses usage inconsistency. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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 --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-01-21 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: ------- |
Copyright © 1999-2021 by the D Language Foundation