Skip to content

Conversation

@hsbt
Copy link
Member

@hsbt hsbt commented Apr 6, 2023

I picked tweak commits from https://github.com/ruby/ruby

Copy link
Collaborator

@schneems schneems left a comment

Choose a reason for hiding this comment

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

One question, no blockers. Feel free to merge.

script.write(contents)

out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest/version #{script} 2>&1`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you give some context for why this change was made? Is it a performance issue or something else?

I’m good with the PR overall but want to preserve some context so if someone refactors this later they will understand the intent.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not performance reason.

-rsyntax_suggest didn't work with make test-syntax-suggest on ruby/ruby repository. It raises uninitialized constant SyntaxSuggest::VERSION (NameError). I'm not sure why they are different result.

Copy link

@AlexWayfer AlexWayfer Apr 10, 2023

Choose a reason for hiding this comment

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

-rsyntax_suggest didn't work with make test-syntax-suggest on ruby/ruby repository. It raises uninitialized constant SyntaxSuggest::VERSION (NameError). I'm not sure why they are different result.

I believe because the lib by default doesn't require version file: https://github.com/ruby/syntax_suggest/blob/b57fe7f/lib/syntax_suggest.rb

I think it's OK practice. We can do in this way, or left it here and just add require_relative 'syntax_suggest/version' in the main lib file.

Nothing of this is performance-related, I think.

Also you can think in this way: if you want to inspect a library, or even a project with this library, where it's required, and you faced some issues, and want to check its version — SyntaxSuggest::VERSION theoretically exist, but there (in irb or pry) also will be the exception without additional require 'syntax_suggest/version'.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think originally I did that as a kind of guard for if the code was loaded or not. But I’m using this now

require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)

so if we want to load the version always I think it’s no problem

Choose a reason for hiding this comment

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

Maybe we should use something like autoload?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer to load the version file instead of autoload.

I remember hitting some edgecase-y things with autoload when working on this. Unfortunately I didn’t write down exactly what those problems were.

Choose a reason for hiding this comment

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

Yeah, I think simple require_relative with single VERSION constant would not make a big impact on performance.

@hsbt hsbt merged commit ee2e4a5 into main Apr 17, 2023
@hsbt hsbt deleted the backport-from-ruby-core branch April 17, 2023 04:39
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.

5 participants