Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In REPL, user defined operators do not persist between lines operator #2245

Open
ribbon-otter opened this issue Sep 3, 2018 · 2 comments
Open
Labels

Comments

@ribbon-otter
Copy link
Contributor

ribbon-otter commented Sep 3, 2018

The Problem

Normal user defined subs persist between calls. If I declare sub a {}, a()works as the next command. This does not work for operators. If a is a infix, the next command will not have a definition for a at all.

Expected Behavior

For custom operators to last between commands. Since other state lasts between commands like this, I would expect for operators to last as well.

Actual Behavior

Custom operators are forgotten for each new command.

Steps to Reproduce

user[~]$perl6
To exit type 'exit' or '^D'
> sub infix:<bb> {$^a + $^b}; 2 bb 2
4
> sub infix:<bb> {$^a + $^b};
sub infix:<bb> ($a, $b) { #`(Sub+{Precedence}|94152335641936) ... }
> 2 bb 2
===SORRY!=== Error while compiling:
Two terms in a row
------> 2⏏ bb 2
    expecting any of:
        infix
        infix stopper
        statement end
        statement modifier
        statement modifier loop

Environment

  • Operating system: Debian 6.3
  • Compiler version (perl6 -v):
This is Rakudo version 2018.06 built on MoarVM version 2018.06

implementing Perl 6.c.

I also reproduced the same problem on a few weeks old recent development build which output this for perl -v:

This is Rakudo version 2018.06-449-gec366c30d built on MoarVM version 2018.06-425-g0daf99bcb

implementing Perl 6.c.
@zoffixznet
Copy link
Contributor

Same as RT#131900. Grammar mutations don't persist in REPL.

@zoffixznet zoffixznet changed the title In REPL, user defined oporators do not persist between lines oporator In REPL, user defined operators do not persist between lines operator Sep 5, 2018
@tinmarino
Copy link
Contributor

We fixed this issue in p6-jupyter-kernel:

  1. Saving the $?LANG from inside the REPL
  2. Updating $!compiler : $compiler.parsegrammar($lang.slang_grammar('MAIN')) at each loop.

Would I make the same PR here ? Extracting information from the "sandbox" with a dynamic variable also ? We still have troubles with pragma persistence, details in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants