Elixir: Add a "Would you like to learn more?" to IEx

Created on 19 Aug 2017  路  10Comments  路  Source: elixir-lang/elixir

There are some events in IEx that can be confusing to newcomers:

  1. When a list of integers is shown as a char list

  2. When the evaluator process crashes

We could detect when those events happen for the first time and offer to provide more information.

IEx Feature Intermediate

Most helpful comment

I wonder what is the correct way to detect that this binary is not char list? I only got ideas about some kind of string parsing, but it looks very complicated, I am not sure it is suitable solution.

I would say the simplest approach is to check if the return type is a char list (i.e. a list of integers) and then we check if the string input does not have the same char list. That would cover most cases.

It is okay that I ask you silly questions? I guess it would be better for you just to implement this feature yourself than to explain every little details to someone like me, but I am really curious about it.

It is actually better if you learn how to do it, because the next time you will contribute other improvements/bug fixes and I will simply have to press merge button. :) So feel free to ask.

All 10 comments

As a newcomer I know that list of printable integers is shown as a char list but I wonder how it is possible to track such event to be happened.

We would need to detect that the input is not a char list and that the output is a char list, this can be done in IEx.Evaluator.

Thank you @josevalim
It would be awesome if I could make it but I am affraid it is too much for me right now.
I will look at IEx.Evaluator.

@josevalim suppose I wrote a = [67,68] in iex.
Than eval function would receive binary "a = [67,68]\n".
I wonder what is the correct way to detect that this binary is not char list? I only got ideas about some kind of string parsing, but it looks very complicated, I am not sure it is suitable solution.

It is okay that I ask you silly questions? I guess it would be better for you just to implement this feature yourself than to explain every little details to someone like me, but I am really curious about it.

I wonder what is the correct way to detect that this binary is not char list? I only got ideas about some kind of string parsing, but it looks very complicated, I am not sure it is suitable solution.

I would say the simplest approach is to check if the return type is a char list (i.e. a list of integers) and then we check if the string input does not have the same char list. That would cover most cases.

It is okay that I ask you silly questions? I guess it would be better for you just to implement this feature yourself than to explain every little details to someone like me, but I am really curious about it.

It is actually better if you learn how to do it, because the next time you will contribute other improvements/bug fixes and I will simply have to press merge button. :) So feel free to ask.

@ivanovaleksey @josevalim looks like this hasn't been worked on since August, is this going to make it into 1.6.0 or can others give it a shot?

Sorry guys I haven't enough time to accomplish this. @acconrad you are welcome to implement it!

@josevalim okay so I think I have the first case covered, a few questions for clarification:

  1. is something like this desired?
iex> 'h茅llo'
NOTE: When a list is made of non-negative integers, it can also be displayed as a charlist.
[104, 233, 108, 108, 111]
  1. state.history the right object to be checking for if this kind of expression has been called before?

  2. What would an evaluator process crash look like? How would I try that out in iex? I'm assuming this isn't the same as adding documentation to this error function: defp handle_eval({:error, {line, error, token}}, _code, _line, _iex_state, _state) do

  3. For testing, how do I run my development iex instead of the one I already have installed on my machine? I tried doing this but it didn't seem to print out my console prints: elixirc lib/iex/lib/iex/evaluator.ex -o lib/iex/ebin && bin/iex

  1. it is the opposite, when you have a list and it is shown as a charlist.

  2. no need to traverse the history. instead we need to store in a file that we have already shown it.

  3. don't worry about that now. let's do either the list or the crash one first.

  4. you need to use bin/elixirc to compile. everything else should be fine though.

Folks, after some discussion, we have decide to close this issue because we could not come up with good and cheap heuristics for detecting lists that become charlists. We are also concerned with the fact that simply running IEx may now store local information. Thanks for everyone who contributed and participated in the discussions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GianFF picture GianFF  路  3Comments

andrewcottage picture andrewcottage  路  3Comments

alexrp picture alexrp  路  4Comments

ericmj picture ericmj  路  3Comments

cmeiklejohn picture cmeiklejohn  路  3Comments