azawawi / farabi6

Experimental in-browser Perl 6 Editor
Artistic License 2.0
14 stars 12 forks source link

Perl 6 Web-based REPL #9

Open azawawi opened 11 years ago

azawawi commented 11 years ago

See https://github.com/perl6/nqp/blob/master/src/HLL/Compiler.nqp#L54

use v6;

use IO::Capture::Simple;

my $save_ctx;
my $comp = nqp::getcomp('perl6');
while 1
{
    my $code = prompt("> ");
    my ($out, $result);
    try
    {
        capture_stdout_on($out);
        $result = $comp.eval($code, :outer_ctx($save_ctx));
        capture_stdout_off;

        CATCH
        {
            default
            {
                capture_stdout_off;

                say "Error: $_";
                say $_.backtrace.Str;
            }
        }
    }

    say("result => " ~ $result) if defined $result;
    say("stdout => " ~ $out) if defined $out;
}

# vim: ft=perl6
azawawi commented 9 years ago

PerlJam told me about Proc::Async that has now landed into 2014.09 MoarVM. I am going to try it and report back.

perl6 IRC Chat

http://irclog.perlgeek.de/perl6/2014-10-09#i_9481283

Proc::Async (Rakudo) https://github.com/rakudo/rakudo​/blob/nom/src/core/Proc/Async.pm

Proc::Async examples and documentation http://perlcabal.org/syn/S17.html#Inter-Process_Communication_exposed_as_Promises_and_Supplies

azawawi commented 9 years ago

Proc::Async wont do anything until perl6 decides to act as REPL and not executing -e programs instead.

Stalling until fixed on the perl6 side

timo commented 9 years ago

the REPL we have at the moment has a problem:

1.) defining a value and refering to it later gives a "not declared" error 2.) the error causes the whole farabi6 process to die