Open wolverian opened 12 years ago
Since I'm learned with the debugger, I've never caught the REPL bug myself, but I understand the utility.
Two questions to get things started: What makes a good REPL? Can we just ship Devel::REPL?
There are a few basic things a REPL must do:
And it should support the following:
And it would be nice if it supported some of these features:
Data::Dump
)There is a ton of other stuff you could do; http://pry.github.com/ is a pretty REPL to take inspiration from.
In the short term, shipping Devel::REPL and advertising it would be fine by me. In the slightly longer term, I'd like to investigate if it could be enhanced to be a more complete REPL than it is right now, along the lines of pry.
Good list. My nits...
I was going to disagree, but that's how the debugger works and I've never had a problem.
Is require/use/do insufficient? Or are you referring to REPL plugins?
Eeeeeerch... nice feature, not so easy in Perl. Maybe a simpler alternative is to have a hotkey which opens up $EDITOR
where you can type in and edit a command. Bonus points if it's split screen with something like curses! If the hotkey is pressed while some code is already typed in, this shows up in the editor.
I'd call that critical. And we have plenty of existing ways to do it.
This calls into question whether printing the return value of each line is a normal stringification or a dump. A dump would be nice, except every once in a while you'll get a vomit as some huge nested object comes out, like with DBIx::Class. So I'd say stringification by default.
For example...?
I'd also like a repl. Some notes:
Eval::WithLexicals is perfect for this. It even have a tiny repl script in the SYNOPSIS.
Personally I do prefer dumps over stringification, perhaps this could be configurable.
Devel::REPL actually already does most of this via plugins, e.g. multiline editing via detecting multiline constructs with PPI. (Whether PPI is something perl5i wants to use is another matter.)
Is require/use/do insufficient? Or are you referring to REPL plugins?
It probably is sufficient. As for plugins, I'd rather I didn't need to load a bunch of plugins just to get a usable REPL. :)
- Show the lexical environment For example...?
Get a list of lexical variables, like with B::LexInfo or such.
Hi I like the idea of a smaller simpler REPL that would come with perl5i, but for right now Devel::REPL is a great tool and some of what it requires is already installed with perl5i.
Devel::REPL's "re.pl" script looks for "$HOME/.re.pl/repl.rc" and runs statements in that file as if they are being executed from the REPL commandline. You can also name profiles under $HOME/.re.pl/ and call re.pl with --rcfile. I seem to be successfully using re.pl with perl5i using this rcfile:
# $HOME/.re.pl/p5i
# call this profile with re.pl --rcfile p5i
use perl5i::latest ;
use indirect ; # this is needed last
Without 'use indirect ;' I get this error: Error executing script /home/user/.re.pl/p5i: Indirect call of method "_hints" on object "$_REPL" at (eval 376) line 10.
daxim on IRC pointed out that use indirect; is the work-around for this since LexEnv's support is incomplete. So to quote daxim this is "not a perl5i bug".
ps: Running two copies of re.pl (one with 'use perl5i::latest;' and one without) in a tmux or screen split screen or in a couple of xterms is a fun and educational way to experiment with classic versus Modern/p5i idioms of "Pumpkin Perl" ;-)
It'd be nice if Perl5i included an easy way to get a REPL running, e.g.
perl5i -r
oripb
(likeirb
from Ruby). There are problems with reserving a command line flag, of course, andipb
is just ugly.re.pl
is cute, but it doesn't ship with Perl5i.I think this is in the scope of Perl5i. (I think it's in the scope for Perl itself!)