icr
icr copied to clipboard
Enable function listing with tab
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
@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.
I think these #79 #97 are supporting the idea