[Issue 6442] Allow for passing values with the 'ref' keyword

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 6 15:41:23 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6442



--- Comment #6 from wfunction at hotmail.com 2011-08-06 15:41:18 PDT ---
> This feature improves code readability, but in D you also have "const ref" that
semantically-wise for the caller is not that different from a pass by value.

Const ref has nothing to do with this. It's almost always an optimization
issue, not a semantic issue. Ref/out is not for optimization: it's for
documentation of the code. Considering that D does not even require variables
to be initialized, it's at least helpful to be able to say, "Yes, I **DO**
expect this variable to get a value after this function returns" at the call
site.


John: It's pretty interesting how you always like the status quo (or just hate
my ideas in general). You've pretty much opposed every /single/ idea I've
proposed, arguing that you don't see a point to it, it's not that useful,
etc... but honestly, does /every/ programmer have to see a point to /every/
feature in a language in order for that feature to be potentially useful?
Unless you can think of a /disadvantage/ here (other than the usual "clutter"
argument, which you can blindly apply to any feature in any language for which
you don't see a point), the fact that you would never use because you can't
think of an advantage doesn't really say anything in itself.
It should be obvious that I'm not arguing for D to be a clone of C#. But there
ARE good features in C#, mind you -- and documenting ref/out parameters is one
of them. It's easy to type (4 letters total, including the space) and it
IMMENSELY improves readability (especially since D doesn't even enforce
initialization). Sure, you might never use it... and neither do I use "final
switch". But does that mean it's a bad idea?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list