2 ms·
If you're not willing to use CPAN, there is no point in using Perl. (Incidentally, have you ever read code.py? Very inflexible and largely useless except for
by jrockway 16y ago
If you're not willing to use CPAN, there is no point in using Perl.
(Incidentally, have you ever read code.py? Very inflexible and largely useless except for the exact purpose it's implemented for, a terminal-based REPL with no history or tab completion.
I needed to write something like this:
https://github.com/jrockway/stylish-perl https://github.com/jrockway/stylish-perl
for Python, and simply couldn't do it without a clever AST rewrite, which added the equivalent of __result__ = <whatever they typed in that can be an rvalue>. Then it was all easy, although it still doesn't quite work right (but I feel if I knew what I was doing and cared, it could be fixed).
As to why stylish-python is not on Github; I wrote it for "work Python" instead of real Python. Yes, we have a fork of Python 2.6 that uses an internally-developed Redis clone to store the source code instead of files. This was not my idea and I did not write any of the code :) (Writing your own database and your own IDE is a lot more fun than writing ETL code, I guess.)
Also, with respect to repr vs. Data::Dump::Streamer, I'll just paste the following REPL sessions:
[~] 0 (jon@snowball2)
$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> repr(lambda (x): return x)
'<function <lambda> at 0x7f6103dda668>'
>>>
[~] 0 (jon@snowball2)
$ re.pl
$ sub { my $x = shift; return $x }
$CODE1 = sub {
package Devel::REPL::Plugin::Packages::DefaultScratchpad;
use warnings;
use strict 'refs';
my $x = shift @_;
return $x;
};
Note how DDS can represent all of Perl's data structures, not just some of them. You now know that you have the identity function instead of a function at memory address 0x7f6103dda668. I guess Python programmers don't care because everything has a name.
Also, with re.pl, you can do this later on in your session:
$ $CODE1->(42)
42
That lambda you typed in in the python shell is gone forever, which IMHO defeats the purpose of having a REPL.