icr icon indicating copy to clipboard operation
icr copied to clipboard

Enable function listing with tab

Open lowks opened this issue 6 years ago • 2 comments

It would be great if icr can list down all the functionality of a type say an integer in icr. The example below is taken from IPython screen shot 2018-01-10 at 11 09 53 am

lowks avatar Jan 10 '18 03:01 lowks

@lowks well, probably. Personally, I'm against this unless icr becomes a fully functional REPL see #79. Currently icr mostly used to quickly try few language features the user not confident with, so it takes only few minutes to interact with this app and probably most users will not need function listing. But, I may be wrong.

Crystal is compiled, which again brings some limitations and complexity in the implementation of this. But I found it still possible to do:

class Object
  def methods
    {{ @type.methods.map &.name.stringify }}
  end
end

10.methods.grep /^to_i/ # => ["to_i", "to_i8", "to_i16", "to_i32", "to_i64", "to_i128"]

If you are willing to try to implement it, please send a pull request, even on early stages. I will be happy to review.

veelenga avatar Jan 10 '18 07:01 veelenga

I think these #79 #97 are supporting the idea

KINGSABRI avatar Mar 29 '18 16:03 KINGSABRI