Skip to content

Conversation

@tompng
Copy link
Member

@tompng tompng commented Aug 30, 2023

Removes the last RubyLex's instance variable @prompt and @line_no.

Reason:
@line_no is completely controlled by IRB::Irb with @scanner.increase_line_no. It should be IRB::Irb's instance variable.
@scanner.set_prompt do end and @scanner.prompt(args) seems roundabout.
I wanted to remove save_prompt_to_context_io because the flow is complex and hard to understand.

After deleting @prompt and @line_no from RubyLex, RubyLex will have no state at all. RubyLex does not have to be a class anymore.

@tompng tompng force-pushed the stateless_rubylex branch from a9744da to ec52279 Compare October 11, 2023 14:56
@tompng tompng force-pushed the stateless_rubylex branch from ec52279 to f1aef4a Compare October 11, 2023 15:05
@tompng tompng marked this pull request as ready for review October 11, 2023 15:12
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Currently we don't declare private methods under IRB::Irb, but I think these 2 prompt methods can be the first 2. WDYT?
While we expect Irb to be a private component, it's still relatively easy to retrieve (e.g. with irb_context.irb) and could be used by us in other gems too (e.g. ruby/debug#1024). So making some methods private could ideally make people think twice before calling them.

@tompng tompng merged commit 1ceb97f into ruby:master Oct 12, 2023
@tompng tompng deleted the stateless_rubylex branch October 12, 2023 12:53
matzbot pushed a commit to ruby/ruby that referenced this pull request Oct 12, 2023
(ruby/irb#701) * Remove instance variable prompt and line_no from RubyLex * Fix prompt test * Rename prompt generating method and make it private ruby/irb@1ceb97fe2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants