Skip to content

[AST] NFC: Metaprogram DeclAttrOptions #16014

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

Merged

Conversation

davezarzycki
Copy link
Contributor

Adding new Decl nodes shouldn't be harder than necessary.

@davezarzycki
Copy link
Contributor Author

@swift-ci please smoke test

@@ -181,6 +181,13 @@ enum class DeclKind : uint8_t;

/// Represents one declaration attribute.
class DeclAttribute : public AttributeBase {
// XXX -- We cannot use DeclKind due to layering.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we use "XXX" anywhere else in the code base. Please use "Note:" or "FIXME:" instead, depending on whether you think this should ever get fixed.

As for the actual comment, I think you should point out that it's okay if this isn't 1-to-1 with DeclKind, since it's just used to build up DeclAttrOptions. It should also probably be an enum class to not infect the DeclAttribute namespace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting, because I had always thought I was the first one to use "XXX" or "xxx" in that fashion. It was a hack, and I agree with @jrose-apple about not introducing it into this code base. But I would love to be able to trace down the meme. Did I copy it from somewhere and just forget? Did a chain of others copy it from me??? I know I used it in the Self VM back in the late 80's.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a perfectly normal convention these days, and I've seen it in many codebases. I just don't want to add more such conventions to this codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrose-apple — Are you okay with HACK? What tags are acceptable? For whatever it may be worth –  I suspect that some nontrivial part of the existing XXX usage in Swift is my fault.

@davidungar – I used to maintain Apple's "Darwin OS", and a part of that work, I saw XXX used in lots of old-school Unix/open-source projects. That's probably where I picked up the habit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HACK is around, but this isn't a hack. If it were, you should just move the DeclKind enum into its own header.

Copy link
Contributor Author

@davezarzycki davezarzycki Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've elaborated the comment and switched to NOTE.

@gottesmm
Copy link
Contributor

As an aside, @davezarzycki/@jrose-apple sounds like something that should be documented somewhere. I know we don't have a swift style guide at this point, but maybe it would make sense to add one for swift specific things?

NOTE I am just asking questions, I haven't thought through all of the issues.

Adding new Decl nodes shouldn't be harder than necessary.
@davezarzycki davezarzycki force-pushed the nfc_metaprogram_DeclAttrOptions branch from 8a2f085 to 0c4c02d Compare April 18, 2018 21:36
@davezarzycki
Copy link
Contributor Author

@swift-ci please smoke test

@davezarzycki
Copy link
Contributor Author

@jrose-apple and @gottesmm – Food for thought for whenever the "mandatory but not enforced code review" document is written: when does review feedback border upon "nitpicking"?

While I think that the quality of the source comment in this pull request improved after your feedback, I'm not sure the feedback itself was necessary. Some people are just more terse or verbose than others when they write code. And reasonable people can disagree about whether something is a HACK or not. Personally speaking, unless terseness or verbosity becomes actively harmful, I let things slide during code review on the theory that nitpicking comments discourages the act of commenting altogether.

@jrose-apple
Copy link
Contributor

I'm easier on the nitpicks on new contributors, but repeat contributors have a responsibility to not just add something but also to keep the codebase from fragmenting (further?) into many different styles and idioms. Having a second person look at your code helps keep it homogeneous between at least two people and hopefully across a larger chunk of the project.

In this case I really didn't get the DeclKindIndex originally, and it took me a while to prove to myself that it didn't matter if it diverged from the real DeclKind. I probably should have swapped the two bits of feedback, though.

@davezarzycki
Copy link
Contributor Author

@jrose-apple, @davidungar, @rjmccall – Ping. I think I've incorporated all review feedback. Can one of you please mark this as reviewed? Thanks!

@davezarzycki davezarzycki mentioned this pull request Apr 19, 2018
Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems okay to me!

@davezarzycki davezarzycki merged commit 135425c into swiftlang:master Apr 19, 2018
@davezarzycki davezarzycki deleted the nfc_metaprogram_DeclAttrOptions branch April 19, 2018 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants