Giter Site home page Giter Site logo

reply's People

Contributors

creaktive avatar doy avatar ilmari avatar jbarrett avatar michaelr avatar sartak avatar sergeyromanov avatar tobyink avatar tokuhirom avatar xsawyerx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reply's Issues

errors with lexical subs

Environment key '&foo' should start with @, %, or $ at /home/doy/perl5/perlbrew/perls/perl-5.18/lib/site_perl/5.18.0/Reply/Plugin/Defaults.pm line 61.

extra arguments get caught in Plugin::Defaults ?

I don't know if it's just me, but when I try to specify some options to reply, Plugin::Defaults complains

> reply -I /path/to/myplugin/lib --cfg /path/to/myconfig.cfg
Can't open -l: No such file or directory at /path/tol/lib/perl5/Reply/Plugin/Defaults.pm line 40.
Can't open -I: No such file or directory at /path/to/lib/perl5/Reply/Plugin/Defaults.pm line 40.
Can't open --cfg: No such file or directory at /path/to/lib/perl5/Reply/Plugin/Defaults.pm line 40.
Use of uninitialized value $package in concatenation (.) or string at /path/tol/lib/perl5/Reply/Plugin/Defaults.pm line 58, <> line 1.
> syntax error at (eval 29) line 4, at EOF
BEGIN not safe after errors--compilation aborted at (eval 29) line 9, <> line 1.

> 

Seems like Plugin::Defaults::read_line() is accessing <>, and in turn @argv. @argv is untouched (and has -I, --cfg in it) because Reply::new is calling getopt against @argv, and leaves @argv untouched, I think.

More command-line argument processing

Running reply -e'my $foo = 42' should enter the reply shell, and run the given code as the first evaluation. So I should end up looking at something like this:

$ reply -e'my $foo = 42'
0> my $foo = 42
$res[0] = 42

1> _

Similarly, running reply foo.pl should load and run foo.pl; If foo.pl contained just print "Hello World\n"; then I should end up with something like this:

$ reply foo.pl
0> require "foo.pl"
Hello World
$res[0] = 1

1> _

In other news: I've finally found a use case for <blink> — that underscore is supposed to represent the cursor — and GitHub's implementation of Markdown strips it out. :-(

unexpected output from map

env:

Reply --version -> 0.38
Perl -v -> v5.22.1

test:

my $squared_results = map { $_**2 } 1..5

expected:

$res[1] = [
1,
4,
9,
16,
25
]

got:

$res[8] = [
'1',
'4',
9,
'16',
25
]

Add options for Term::ReadLine title and *IN / *OUT

It is hardwired to 'Reply' at the moment.

Also, is it possible for Reply to support options for IN and OUT handles? I'm trying to implement a standard command interface that could be used by a GUI "front end" by communicating via the IN/OUT handles.

I'm also looking at syntax highlighting for a CLI especially for tab completion where the various possibilities might come from different plugin sources.

Negative zero is misprinted as zero

In floating point math, there is a representation for a negative zero. In both re.pl and reply, a negative zero value is incorrectly printed as '0'. Observe the first 5 expressions here:

$ reply
0> log(1)
$res[0] = '0'    ← Weird to see it quoted as a string, but not wrong.

1> - log(1)
$res[1] = '0'    ← Wrong!

2> my $x = -log(1)
$res[2] = '0'

3> $x
$res[3] = '0'    ← Wrong!

4> print $x
0$res[4] = 1    ← Wrong! print also incorrectly prints it as zero.

5> sprintf("%f", $x)
$res[5] = '-0.000000'    ← See? $x was negative zero.

6> $x < 0
$res[6] = ''

7> $x > 0
$res[7] = ''

8> $x == 0
$res[8] = 1

9> $x eq '0'
$res[9] = 1    ← Huh, wat?

10> $x eq '-0'
$res[10] = ''    ← Wat‽

System:

  • Perl version 5.28.1
  • Reply version 0.42
  • Ubuntu Linux on amd64/x86_64 arch

Further references:

Warn, don't die, on bad/missing plugins or missing optional dependencies

Some plugins require modules that are not listed in the prereqs for Reply. If these plugins are enabled in the config file, and these optional modules aren't installed, reply dies. The user winds up going through several rounds of die, install missing module, die, ... It would be better for the user if on startup, they could see a list of all warnings, and install everything in one go. The two common problems to guard against are adding a plugin in the config that isn't installed yet (possible typo or user adds plugin not realizing it's not a builtin), and using a builtin which has undeclared dependencies.

accessing lexical variables from inside a named sub

Say I have the following code:

my $factor = 2;
sub mult_by_factor {
    $factor * shift;
}
say mult_by_factor(21);

This works when used in a regular Perl script, but not at the REPL. I know it might not be the best practice, but it can come in handy when testing things out.

There is are work arounds:

my $factor = 2;
*mult_by_factor =  sub {
    $factor * shift;
};
say mult_by_factor(21);

or

our $factor = 2;
sub mult_by_factor {
    $factor * shift;
}
say mult_by_factor(21);

This might be worth documenting at least.

Reply::Plugin::ReadLine broken for PERL_RL=perl (a.k.a. Term::ReadLine::Perl)

I found two problems with the support for Term::ReadLine::Perl in the Reply::Plugin::ReadLine:

  • On my system, $self->{term}->ReadLine returns 'Term::ReadLine::Perl' and not '...::Perl5'
  • Term::ReadLine::Perl version 1.0303 does not have a WriteHistory() routine.

I see there is now a Term::ReadLine::Perl5 module which is the one that is actually supported. I'll install and test that. It should be specified as a requirement since for non-gnu-readline platforms, it may be the only Term::ReadLine engine supported.

ReadLine plugin can't handle quoted paths, but the pod implies it can

(I commented in #48 about this, but I'm guessing you didn't see it because the ticket was closed at that point.)
The pod example shows shows the history_file option can take a quoted path, but that is actually not the case.
This works: history_file = ~/.reply_history
This doesn't: history_file = '~/.reply_history'.
If you use $history = glob($history) instead of $history =~ s{^~/}{$ENV{HOME}/} it will properly deal with the quotes, though it might be better dealing with them at the config reader level.

Support for multiple line input?

Was asked about this by a colleague,
would there be a decent way to enable multiline support,
like [ReadTilSemicolon] or something. Then you could do:

my $a = {
    c => 'd'
 };

lexical variables escape from blocks

On Reply 0.34, Perl 5.18.2, default .replyrc, lexical variables within blocks escape their scope:

0> { my $x = 3 }; 
$res[0] = 3
1> $x
$res[1] = 3

It doesn't seem to matter how deep I try to bury them:

0> for (0) { for (0) { my $sksk = 3 } }
$res[0] = ''
1> $sksk
$res[1] = 3

Lexical persistence is on via the LexicalPersistence plugin, but I assumed it would only apply to variables outside of blocks. Bad assumption?

Bare heredoc

I tried to use a bare heredoc in the repl session and something amazing happened:

1> my $x = <<
Use of bare << to mean <<"" is deprecated at reply input line 1.
Use of uninitialized value $^WARNING_BITS in concatenation (.) or string at reply input line 1.
$res[0] = ';
BEGIN {
    201330658 = 256;
    HASH(0xd2fe70) = %^H;
    UUUUUUUUUUUUUUUUU� = ;
}
'

wishlist: #vars (or similar) to show current variables

Hi doy! Thanks a lot for Reply - it's really cool :)

I was wondering if there is a way to see a list of all the variables currently available in the REPL. Specifically, I mean the ones created via my/our/state by the user.

Right now the only way I know how to do it is by either peeking at the history or having tab completion on and doing $a[tab], $b[tab] etc, but it does expand to other stuff as well.

For example:

> my $foo = 42
> my @meep = qw( some values )
> my $schema = My::Schema->connect( "..." );
> #vars
$foo
@meep
$schema

Ideally, it would show values as well, but it doesn't have to be that fancy (specially since values can be huge, and the user can just type "@meep" anyway after "#vars" to see its content anyway)

Would this fit into your vision for Reply?

cannot use feature 'say'

$ perl -mfeature=say -mReply -e 'Reply->new()->run;'

say "hello"
String found where operator expected at reply input line 1, near "#line 1 "reply input"
say "hello""
(Missing operator before "hello"?)
syntax error at reply input line 1, near "#line 1 "reply input"
say "hello""

undef warnings on startup

$ cpanm Reply
--> Working on Reply
Fetching http://www.cpan.org/authors/id/D/DO/DOY/Reply-0.17.tar.gz ... OK
Configuring Reply-0.17 ... OK
Building and testing Reply-0.17 ... OK
Successfully installed Reply-0.17 (upgraded from 0.01)
1 distribution installed
$ reply
Can't use an undefined value as a HASH reference at /Users/sartak/.perl/perls/perl-5.18.0/lib/site_perl/5.18.0/Reply/Plugin/Defaults.pm line 57.
Can't use an undefined value as a HASH reference at /Users/sartak/.perl/perls/perl-5.18.0/lib/site_perl/5.18.0/Reply/Plugin/Defaults.pm line 57.
Can't use an undefined value as a HASH reference at /Users/sartak/.perl/perls/perl-5.18.0/lib/site_perl/5.18.0/Reply/Plugin/Defaults.pm line 57.
0>

Useless dependency on Devel::LexAlias

META lists Devel::LexAlias as a dependency, but the module is nowhere used in the code. Git history shows it used to be loaded from lib/Reply/Plugin/Defaults.pm.

Want to contribute my code to reply

Hi,

I have written a plugin and would like it to be published. Here is a short description:

NAME
    Reply::Plugin::ConfigPrompt - provides a prompt that can be configured
    in the config file

VERSION
    version 0.01

SYNOPSIS
      ; .replyrc
      [ConfigPrompt]
      format = fixed_string %T %d %p %c >
      color  = bright_green

DESCRIPTION
    This plugin enhances the default Reply prompt. It allows for the prompt
    to display in a chosen color using the "color" option. It also
    allows user to test a prompt format before using it for his application.

AUTHOR
    Balaji Ramasubramanian <[email protected]>

COPYRIGHT AND LICENSE
    This software is Copyright (c) 2016 by Balaji Ramasubramanian.

    This is free software, licensed under:

      The MIT (X11) License

If you give me permission to contribute, I would be happy to add my code to a branch on your repository. Then you can pull it, review it and integrate it in the next release.

Thanks,
Balaji

reply doesn't work on 5.22 on my system

Mark@travis:/tmp$ reply
> 1
Use of uninitialized value $package in concatenation (.) or string at /opt/markperl/lib/site_perl/5.22.0/Reply/Plugin/Defaults.pm line 55, <STDIN> line 1.
syntax error at (eval 25) line 4, at EOF
BEGIN not safe after errors--compilation aborted at (eval 25) line 9, <STDIN> line 1.

> ^D
Mark@travis:/tmp$ perl -v

This is perl 5, version 22, subversion 0 (v5.22.0) built for darwin-2level

Copyright 1987-2015, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Mark@travis:/tmp$ perl -e 'use Reply; print $Reply::VERSION'
0.37
Mark@travis:/tmp$ ~/perl5/perlbrew/perls/perl-5.18.2/bin/reply
> 1
Use of uninitialized value $package in concatenation (.) or string at /Users/Mark/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Reply/Plugin/Defaults.pm line 55, <STDIN> line 1.
syntax error at (eval 28) line 4, at EOF
BEGIN not safe after errors--compilation aborted at (eval 28) line 9, <STDIN> line 1.
Mark@travis:/tmp$ ~/perl5/perlbrew/perls/perl-5.18.2/bin/perl -e 'use Reply; print $Reply::VERSION'
0.37

lexical persistence

hi!
Is it possible to overcome this behavior?

~$ reply
0> my $v = 0;
$res[0] = 0

1> my $inc = sub { ++$v }
$res[1] = sub { "DUMMY" }

2> $inc->()
$res[2] = 1

3> $v
$res[3] = 1

4> $v = 0
$res[4] = 0

5> $inc->()
$res[5] = 2

6> $v
$res[6] = 0

Autocompletion::Package misses $PERL5LIB ones

For organization, I install my local modules into an INSTALL_BASE location with the appropriate PERL5LIB environment variable set. Just noticed that any package in that location was not present in the all_packages() and hence the completion for 'use XXX'

This was true for Strawberry Perl Portable 5.19.11.4 and cygwin64 perl 5.14.4

Why hand-rolled OO and not Moo for Reply?

I'm working on some PDL development using Moo
for its support of modern OO features and because
it is compatible with full Moose if needed.

In addition, I plan to move the pdl2 interactive shell
implementation from one based on Devel::REPL to
one built with Reply due to its improved startup
file support (more sh-ish!) and the simplicity.

In trying to minimize code duplication, I was wondering
what the design goals were for a more hand-rolled
OO implementation (classic perl5) versus using Moo.
I was thinking to try refactoring Reply to use Moo and
was wondering if you see any benefits or problems
with that?

Thanks,
Chris

How about use perl not dosini as the config language

I notice ~/.replyrc is a dos ini file and if user want to customize something, they should create a perl plugin and enable it in ~/.replyrc

It looks like weird. Why not use perl directly as config language? Like ptpython or ipython which are python REPLs using ~/.config/ptpython/config.py and ~/.ipython/profile_default/ipython_config.py as their config files. Even if cpython also allow user use $PYTHONSTARTUP ( a python file ) to config its REPL.

Just an advice for discussion. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.