Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 23, 2013 [Issue 10150] New: Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10150 Summary: Prefix method 'this' qualifiers should be just ignored anytime Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: k.hara.pg@gmail.com --- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-23 06:23:11 PDT --- By fixing issue 9199, git head rejects all meaningless method qualifiers for non-method functions. class C1 { const static void fc() {} // NG in both 2.062 and git head immutable static void fi() {} // NG in both 2.062 and git head shared static void fs() {} // OK in 2.063 but NG in git head inout static void fw() {} // OK in 2.063 but NG in git head } class C2 { static void fc() const {} // NG in both 2.062 and git head static void fi() immutable {} // NG in both 2.062 and git head static void fs() shared {} // OK in 2.063 but NG in git head static void fw() inout {} // OK in 2.063 but NG in git head } const void fc1() {} // NG in both 2.062 and git head immutable void fi1() {} // NG in both 2.062 and git head shared void fs1() {} // OK in 2.063 but NG in git head inout void fw1() {} // OK in 2.063 but NG in git head void fc2() const {} // NG in both 2.062 and git head void fi2() immutable {} // NG in both 2.062 and git head void fs2() shared {} // OK in 2.063 but NG in git head void fw2() inout {} // OK in 2.063 but NG in git head --- But this behavior is restrictive and now breaking exist code. Dlanguage allows to rewrite prefix storage class to label syntax and scope syntax. const void foo() {} // previous const: void foo() {} // label const { void foo() {} } // scope Making errors for the functions enclosed by attribute would be inconvenient. So, I'd like to propose that: 1. Module level functions and class/struct scope static functions just ignore prefix method 'this' qualifiers (const, immutable, shared, and inout). 2. But specifying them at postfix position should be rejected. The rule is consistent and make writing code more handy. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 23, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-23 08:01:02 PDT --- https://github.com/D-Programming-Language/dmd/pull/2071 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 24, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 --- Comment #2 from github-bugzilla@puremagic.com 2013-05-24 01:39:30 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/958abf2c48333cc0f800dff51da435338458b751 fix Issue 10150 - Prefix method 'this' qualifiers should be just ignored anytime https://github.com/D-Programming-Language/dmd/commit/091cb6eea52eec998f60d8e6be6b54413d173b3b Merge pull request #2071 from 9rnsr/fix10150 [enh][REG2.063a] Issue 10150 - Prefix method 'this' qualifiers should be just ignored anytime -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 24, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 --- Comment #3 from github-bugzilla@puremagic.com 2013-05-24 01:40:33 PDT --- Commit pushed to 2.063 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7c3ed3e585e829c7bf97ca8f78b6c7d76c98b0ba Merge pull request #2071 from 9rnsr/fix10150 [enh][REG2.063a] Issue 10150 - Prefix method 'this' qualifiers should be just ignored anytime -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 24, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 27, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-06-27 11:26:24 PDT --- I disagree with this change, this is extremely dangerous behavior when interfacing with C. Take a look at the following: ----- extern(C) const int *foo(); void main() { *foo() = 1; // compiles } ----- The proper definition should have been: ----- extern(C) const(int)* foo(); void main() { *foo() = 1; // fails } ----- It is very easy to make this mistake, it should not be silent, at least not for module-scoped functions. Alternatively as a compromise I suggest we at least add this check for extern(C) functions, because this is where this problem can occur very frequently. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 27, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 --- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-06-27 11:28:34 PDT --- Another alternative is to make the compiler smarter, and only disallow const where it's only applied to one function, for example: ----- const int * foo(); // disallowed const { int * foo(); // ok int * bar(); // ok } const: int * foo(); // ok ----- This would be for the sake of convenience, to avoid breaking existing code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 30, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 Dicebot <m.strashun@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.strashun@gmail.com --- Comment #6 from Dicebot <m.strashun@gmail.com> 2013-06-30 10:35:25 PDT --- I think "const T foo" should be parsed as "const(T) foo" where T is not void and be an error otherwise. (I was almost certain that former was how it has behaved before!) This is a very natural style to type in, especially for those that come from C/C++. Silent no-op is probably most dangerous decision possible. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 30, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 --- Comment #7 from Dicebot <m.strashun@gmail.com> 2013-06-30 10:37:35 PDT --- I actually see no rationale behind this change because enhancement descriptions mentions only function returning "void". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 30, 2013 [Issue 10150] Prefix method 'this' qualifiers should be just ignored anytime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=10150 --- Comment #8 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-06-30 10:43:09 PDT --- (In reply to comment #6) > This is a very natural style to type in, especially for those that come from C/C++. Well not entirely, since 'const void *' in D and C++ mean different things, const(void*) vs const(void)*. > Silent no-op is probably most dangerous decision possible. Yep, at least for non-grouped declarations like I've mentioned. -- 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