Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Dsymbol.namespace to cppnamespace #10287

Merged
merged 1 commit into from
Aug 7, 2019

Conversation

edi33416
Copy link
Contributor

@edi33416 edi33416 commented Aug 7, 2019

Because Dsymbol.namespace is a public extern (C++) symbol, the C++ header generator will generate the following code

class Dsymbol : public ASTNode
{
public:
    /* ... */
    CPPNamespaceDeclaration* namespace;
    /* ... */
}

As you know, and see from the syntax highlight, namespace is a C++ keyword, so this generated code won't compile.

This PR renames only the public symbol Dsymbol.namespace.
Maybe it should rename all of the namespace occurrences?

I think, in my humble opinion, that we should avoid using other programming languages keywords as public symbols.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @edi33416! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

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.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#10287"

@lesderid
Copy link
Contributor

lesderid commented Aug 7, 2019

I think, in my humble opinion, that we should avoid using other programming languages keywords as public symbols.

Wouldn't it be a better idea to handle these issues as special cases in the respective generators?

If it's just C++ (and maybe C and Obj-C) keywords that we have to take special care with, it doesn't pose much of an issue, but it could quickly become one if we want to support other languages. For example, I just googled for a list of Go keywords and apparently range is a keyword in Go.

@Geod24
Copy link
Member

Geod24 commented Aug 7, 2019

I think, in my humble opinion, that we should avoid using other programming languages keywords as public symbols.

Well many languages have many different kind of keywords, and some are very generic. Go's range (or chan), C#'s async and await. Simula has value, comment, begin, before... Well you get the picture.
In this case, I think the generator should just append an underscore (_) like we do when a foreign language name conflicts with a D name (e.g. body)

@andralex
Copy link
Member

andralex commented Aug 7, 2019

Looks like special casing other languages' keywords is more roundabout - people need to run to the manual to figure how their symbols are translated. Just going for straight generation and reasonably asking for due diligence in naming seems appropriate.

@andralex andralex merged commit e6a5df9 into dlang:master Aug 7, 2019
@andralex
Copy link
Member

andralex commented Aug 7, 2019

Hm, thought it was approved and I just pushed "merge". If I was hasty lmk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants