August 07, 2011 [Issue 6442] Allow for passing values with the 'ref' keyword | ||||
---|---|---|---|---|
| ||||
Posted in reply to wfunction@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=6442 --- Comment #20 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-08-07 01:12:16 PDT --- Well, I don't think that the feature adds enough of value to be worth adding to the language. But it's not my decision. Discussion on the matter can help influence Walter's decision, but it's ultimately his decision. And at this point, I think that it's pretty much a guarantee that he's not going to add a feature like this any time soon. That doesn't mean that he'd be forever against it, but he's got a lot on his plate right now, and unless a feature solves a real problem in the language which makes doing things hard or impossible, or it fixes a major inconsistency in the language, it's unlikely that Walter would implement it any time soon. He's just too busy, and at this point, most of the work on dmd is going towards stabilizing it and fixing any rough edges on the language itself which need to be fixed for D to be fully usable (one example was the adding of purity inference; without it, pure was essentially useless with templates, so Walter added it). At some point in the future, if he thought that this feature was worth adding he might add it (particularly since it doesn't break backwards compatibility), but it's just not going to happen right now. The only chance that this has of being implemented right now is if someone else implements it and creates a pull request for it. If someone does that, and Walter thinks that the feature is worth having, then it could be added. But if no one else takes the time to implement it, or if Walter doesn't like the feature, and you can't convince him otherwise, it's not going to be implemented any time soon. Unless someone closes this feature request (which isn't likely to happen unless you decide to do it), it'll stick around for quite a while, and maybe Walter will eventually implement it. But you're probably going to have to wait a while. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 07, 2011 [Issue 6442] Allow for passing values with the 'ref' keyword | ||||
---|---|---|---|---|
| ||||
Posted in reply to wfunction@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=6442 --- Comment #21 from wfunction@hotmail.com 2011-08-07 11:16:43 PDT --- Hmm... /maybe/ I'll try implementing it myself, although I'm not at all familiar with the source code. Let's see how it goes, I'll post here if I get anywhere. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 07, 2011 [Issue 6442] Allow for passing values with the 'ref' keyword | ||||
---|---|---|---|---|
| ||||
Posted in reply to wfunction@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=6442 --- Comment #22 from bearophile_hugs@eml.cc 2011-08-07 13:30:59 PDT --- I have a related but alternative proposal; to ask only for the "out" at the calling point, make it obligatory if you compile with -warning and optional otherwise (for a long time "override" was like this). I think having "out" at the calling point is more useful than "ref". Currently D 2.054 gives no warnings/errors on a program like this (I think the C# compiler gives something here): void foo(out int x) { x = 5; } void main() { int y = 10; foo(y); } The problem here is the initialization of y to 10 always gets ignored. Assigning something to y, *not using y in any way*, and then using it in a "out" function argument call, is code smell. It's wasted code at best, and sometimes it's related to possible semantic bugs. Using "out" at the calling point doesn't fix that code, but helps the programmer to see that the assign of 10 to y is useless, and it's better to remove it: void foo(out int x) { x = 5; } void main() { int y = 10; foo(out y); } In my opinion "ref" arguments don't have the same need of being tagged at the calling point because a function that uses "ref" often reads and writes the argument (otherwise you use "in" or "out"), so in a ref argument assigning something to y before the call is more often meaningful: void foo(ref int x) { x++; } int main() { int y = 10; return foo(y); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 07, 2011 [Issue 6442] Allow for passing values with the 'ref' keyword | ||||
---|---|---|---|---|
| ||||
Posted in reply to wfunction@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=6442 --- Comment #23 from bearophile_hugs@eml.cc 2011-08-07 13:42:58 PDT --- See also: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=141999 -- 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