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

Fix modern documentation to mention emit_arg_inside_procarg0 #658

Merged
merged 1 commit into from Mar 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -24,10 +24,11 @@ below for explanation of `emit_*` calls):

require 'parser/current'
# opt-in to most recent AST format:
Parser::Builders::Default.emit_lambda = true
Parser::Builders::Default.emit_procarg0 = true
Parser::Builders::Default.emit_encoding = true
Parser::Builders::Default.emit_index = true
Parser::Builders::Default.emit_lambda = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a good idea to add some comments explaining what those options do.

Copy link
Owner

Choose a reason for hiding this comment

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

There is documentation right above explaining what these options do.

Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation in the backwards compatibility section is extremely generic and doesn't mention any of the options specifically. I'm pretty sure most newcomers would have try some trouble trying to figure out what some of the more weird options mean.

Copy link
Owner

Choose a reason for hiding this comment

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

The fact that we even have these options is a consequence of our errors in judgement earlier. They should never be turned off explicitly, and in particular newcomers shouldn't set them to any other value. If someone really wants to know what they do, reading the source is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough. :-) This can also be made clearer in the docs, but I guess it's not a big deal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They should never be turned off explicitly, and in particular newcomers shouldn't set them to any other value.

That is the reason I propose to expose a (or the) #modernize method and document it. It removes even needing to know the details of what modernize means.

Copy link
Owner

Choose a reason for hiding this comment

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

That is the reason I propose to expose a (or the) #modernize method and document it.

That's impossible. Ever changing what that method does would break backwards compatibility, thus defeating the purpose of having it in first place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's impossible. Ever changing what that method does would break backwards compatibility, thus defeating the purpose of having it in first place.

True. The method itself would have to be versioned, defeating the propose.
For my use cases I'll probably detect "malformed from not modernized" ASTs and reject them early.

Okay, so can we merge the PR as is? I think its an incremental improvement over the current state.

Parser::Builders::Default.emit_procarg0 = true
Parser::Builders::Default.emit_encoding = true
Parser::Builders::Default.emit_index = true
Parser::Builders::Default.emit_arg_inside_procarg0 = true

Parse a chunk of code:

Expand Down