Skip to content

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Jan 10, 2023

Some background/assumptions for this refactor:

  1. Through a RubyLex instance's lifetime, the context passed to its methods should be the same. Given that Context is only initialised once in Irb#initialize, this should be true.

  2. When RubyLex is initialised, the context object should be accessible. This is also true in all 3 of RubyLex.new's invocations.

With the above observations, we should be able to store the context in RubyLex as an instance variable. And doing so will make RubyLex's instance methods easier to use and maintain.

Copy link
Collaborator

@hasumikin hasumikin left a comment

Choose a reason for hiding this comment

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

LGTM

I made a related PR ruby/reline#498

@st0012
Copy link
Member Author

st0012 commented Jan 12, 2023

@hasumikin That's awesome, thank you 👍

@st0012 st0012 force-pushed the store-context-in-lexer branch from 47ca87a to b991c8f Compare January 12, 2023 10:37
Some background for this refactor:

1. Through a RubyLex instance's lifetime, the context passed to its methods
   should be the same.
   Given that `Context` is only initialised in `Irb#initialize`,
   this should be true.

2. When `RubyLex` is initialised, the context object should be accessible.
   This is also true in all 3 of `RubyLex.new`'s invocations.

With the above observations, we should be able to store the context in `RubyLex`
as an instance variable. And doing so will make `RubyLex`'s instance methods
easier to use and maintain.
@st0012 st0012 force-pushed the store-context-in-lexer branch from b991c8f to bdfa4b7 Compare January 12, 2023 11:23
@hasumikin hasumikin merged commit 5c8d3df into master Jan 14, 2023
@hasumikin hasumikin deleted the store-context-in-lexer branch January 14, 2023 09:19
hasumikin added a commit to ruby/reline that referenced this pull request Jan 14, 2023
* Correspond to refactored RubyLex

ref: ruby/irb#503

* Fix test_yamatanooroti
matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 14, 2023
(ruby/reline#498)

* Correspond to refactored RubyLex

ref: ruby/irb#503

* Fix test_yamatanooroti
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.

3 participants