dlang.org icon indicating copy to clipboard operation
dlang.org copied to clipboard

cpptod: add function input and output parameters.

Open carun opened this issue 6 years ago • 2 comments

First attempt to renew PR #1840.

I respect and appreciate the work of the original author. However I think that this PR explains a trivial difference between C++ and D. Please consider if this is really required to be merged.

C++ to D article ought to contain the important differences that eases the transition of a C++ programmer (from his preconceived notions) to D. It should be packed with information. Trivial topics could dilute the focus of this article. Things like struct, RAII, are good places for improvement, I believe.

Just my 2 cents.

carun avatar Jan 11 '18 07:01 carun

Thanks for your pull request, @carun! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

dlang-bot avatar Jan 11 '18 07:01 dlang-bot

I think that this PR needs to be even more accurate.

C++ has only const and volatile (which is a different subject) as qualifiers for function parameters. D improves over C++ by introducing many new qualifiers to the function parameters (in, out, const, immutable, inout, ref and many more, but I'm stating those that are applicable for programmers transitioning from C++) that lets the reader clearly infer what the function does by just look at it's signature. We don't even have to explain what void getArea(in int width, in int height, out int area); does (without even knowing the pass by reference semantics). The function signature is self explanatory.

Both C++ and D support input and output parameters. C++ supports it in the form of pass-by-reference (and pointer). In addition, D improves over C++ by differentiating between value types and reference types and also though the function parameter qualifiers. So in my opinion this PR needs a complete rewrite.

carun avatar Jan 13 '18 07:01 carun