user-experience
user-experience copied to clipboard
Perl6 needs a good REPL
Programmers coming from Ruby, Python, Node, Clojure, (etc) will expect a decent REPL, with history, arrow navigation and tab completion.
Ideally the perl6 executable from Rakudo could be improved to meet these needs. Otherwise a port of the perl5 module Devel::REPL would also work.
@ShaneKilkelly Let's say that rakudo bundled Linenoise so that history, line editing, and tab completion worked out of the box. Would that be enough, or are there more things you would like to have added?
I'd presume so. If it means executing $ perl6 would Do The Right Thing™, then sure, that would be a great solution.
NOTE: I hadn't seen the Linenoise package on modules.perl6.org before it was mentioned here.
Rakudo will support line editing and history if either Readline or Linenoise are available, and tab completion with Linenoise. It also recommends you install one of them if neither is found, but I think I made that change post-Christmas.
Ah, now that's cool. It sounds like this issue should be wrapped up pretty easily then :smiley:
Thanks for bringing it up! The tab completion could probably be improved, as could multi-line editing. We might want to consider bundling Linenoise or a better line editor with Rakudo, but it feels to me like we'll be moving away from bundling modules with Rakudo itself. I can write up some more notes and stick them into this repo.
NP.
I think as long a perl6 noob can install rakudo, type perl6 and have the up-arrow not produce ^[[A, we'll be on the right track.
For people who have tuits in this area, I'd also like to plug the IPython kernel @timo and I have been working on: timo/iperl6kernel. There are some issues in the tracker that can give some ideas on where to start, and I'd be happy to advice if people drop by #perl6.
An OK REPL is clearly important, but I think plugging into something like IPython would give us a pretty good bang for buck factor as well.
Agreed with @arnsholt, a combination of a decent default REPL and a good Jupyter implementation would be awesome.
Where is the issue tracker of the REPL/Linenoise? Have some bugs.
@wollmers, this should be it: https://github.com/hoelzro/p6-linenoise
Didn't know Linenoise supported tab-completion. I'd just used Readline because I figured that was the stock GNU/Linux solution. Had some issues with it (or rakudobrew, or panda, not sure), and then fell back to using rlwrap: $ rlwrap perl6.
Also, aside: although I haven't used it in a while, I remember being impressed with the stock Julia repl. I remember it being colorful, and supporting multiline nicely (in fact, I think you could type a multi-line statement, hit Enter, then up-arrow and get the whole multi-line input again).
@wollmers @zoffixznet REPL bugs should be reported on rt.perl.org; please feel free to CC me!
I'm using Rakudo* on Windows; its suggestions to install Readline or Linenoise aren't too helpful as neither of those install with Panda on this platform.
Since Windows cmd shell supports up-arrow and other basic arrows, the suggestion isn't really needed on this platform.
On the other hand, tab completion is nice. since Linenoise has it with P6 and Readline doesn't, mention that in the default "you can install one of these" message. And consider making Linenoise part of Rakudo* - with it working on Windows of course!
(And a ++to uvtc's suggestion at looking at Julia's REPL, multi-line and colors are nice.)
@fecundf Did you have problems installing Linenoise? I try to make sure it stays working on Windows, but please let me know if there are any problems!
@fecundf Also, Linenoise is in R*, I just screwed up when I added it so it didn't get built =/
@uvtc @fecundf As far as taking inspiration from Julia goes, it's just the multi-line input and the colors? I just spun up Julia's REPL for fun; it seems like it just uses color to differentiate modes; is that what you're after?
Good handling of multi-line expressions is what I'm after. Coloring is less important, half the time I'm using the REPL inside an emacs shell.
In general IMHO when it comes to colors from shell commands, there's always some color that is hard-to-read against some background!
@fecundf Thanks for the feedback; I'm working on a little experiment with multi-line input today!
Coming from lisps/haskell, I would love to have a reference to the last returned result ('it' in ghci), and the ability to load source files. That said with the caveat that I have no sense of what would be involved in making this happen.
@calopter I think that we should at the very least have $_ set. In irb/pry they define a lexical _ to do this, so pretty similar.
to load source files you can just do
EVAL slurp($filename)
Regarding the last returned result, I think we should resist the temptation of setting $_ . That would be a Pythonism, imho, as $_ in Perl is not at all Python's '_'.
Maybe $__? or something semantically close to the topic variable, but still distinct?
For clarity sake, what do you mean by ‘load source files?’
On Aug 31, 2016, at 3:31 PM, Shane Kilkelly <[email protected]mailto:[email protected]> wrote:
Maybe $__? or something semantically close to the topic variable, but still distinct?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/perl6/user-experience/issues/2#issuecomment-243922809, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AB75kI41A3yY0ZQZ0nruTBhKcRNQnw06ks5qlgDBgaJpZM4HFN0p.
If we really want to imitate python we should just use a sigilless _
The last returned value is almost always a read-only one, anyway.
Why not use something readable like $result?
In a long run I don't want to have to explain the difference between $_ and _/$__, maybe we can avoid it?
You want something quick to type. A single character is the best. A sigilless "it" would do too, I guess.
@tony-o To clarify, I mean the ability to enter the namespace of a given module and have access to its bindings. Thus, you could run and interact with individual functions, modify them in the source file, reload and repeat.
I would also like some way of adding new functionalities via plugins. I am still baffled at how Linenoise works. I guess it's got something to do with NativeCall, but I really have no idea.
Just FYI I just installed rakudo on a system running xubuntu and the xfce terminal emulator does not handle REPL well by default. ^[[A when you hit up for history and no tab completion, even after installing linenoise. I'm currently using @uvtc 's suggestion of rlwrap.
ps just checked and readline is also installed, by default I think.
@RichardJActon OOC, what's echo $TERM give you?