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

Don't echo results of assignment expressions #11

Closed

Conversation

2 participants
@onlynone
Copy link

commented Mar 20, 2019

This is a proof of concept for something I'd like to see added to irb. The ability for the interpreter to not echo results of assignment expressions.

I'm guessing this exact patch wouldn't be accepted because:

  1. You won't want to pull in another gem, and
  2. You might want the semantics of the IRB.conf[:ECHO] setting to stay the same (ie true always echos and false never echos)

As to 1: I'm guessing irb and ruby have other ways of doing expression parsing that maybe could be hooked into instead of using the parser gem. I'm just not very familiar with those possible methods, and I found parser easy to use to express the functionality I was looking for.

For 2: Would a third value other than true or false for that setting be acceptable? Like :non_assignment_expressions? Or maybe another setting altogether: IRB.conf[:NO_ECHO_ON_ASSIGNMENT]? So that only when IRB.conf[:ECHO] and IRB.conf[:NO_ECHO_ON_ASSIGNMENT] are true would the advanced echo/noecho logic be used.

@hsbt

This comment has been minimized.

Copy link
Member

commented Mar 20, 2019

We couldn't use the 3rd party gem like parser. Because irb is the part of a standard library of ruby language.

@hsbt hsbt closed this Mar 20, 2019

@onlynone

This comment has been minimized.

Copy link
Author

commented Mar 21, 2019

Hi @hsbt. I understand not being able to use that third party dependency. That was just a starting point so I could show the intended behavior. I was hoping someone more knowledgeable about ruby and irb internals would be able to point me to another, more appropriate, internal, AST parser that I could use instead of the parser gem.

I was hoping that my first implementation would spark discussion of how to properly do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.