[perl #61088] [PATCH] show result of expressions in HLLCompiler based interactive REPLs
Will Coleda via RT
parrotbug-followup at parrotcode.org
Mon Sep 21 06:26:54 UTC 2009
On Sat Dec 06 07:32:54 2008, rff.rff at gmail.com wrote:
> the current HLLCompiler infrastructure seems to be an incomplete REPL,
> since it only does Read-Eval-Loop.
> This patch adds a simple Print step and a new attribute
> commandline_result_prompt similar to commandline_prompt, defaulting to
> "=> ".
> It also changes the default commandline_prompt to " >> " to make the
> two vertically aligned.
>
> A better approach may be splitting the functionality of the
> interactive() method into calls to multiple overrideable methods
> (read, print) to allow further
> customization from users of the class.
>
> the difference is easy to show, with rakudo:
> >> 1
> => 1
> >> 1+3
> => 4
> >> say "hello"
> hello
> => 1
> >> 1.WHAT
> => Int
> >> 1.HOW
> => get_string() not implemented in class 'P6metaclass'
> current instr.: 'parrot;PCT;HLLCompiler;interactive' pc 1072
> (src/PCT/HLLCompiler.pir:592)
> called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1470
> (src/PCT/HLLCompiler.pir:793)
> called from Sub 'parrot;Perl6;Compiler;main' pc 16749 (perl6.pir:166)
>
> vs
> > 1
> > 1+3
> > say "hello"
> hello
> > 1.WHAT
> > 1.HOW
> >
>
> I did not install an exception handler for missing failure in the
> internal say() call cause it feels this should not happen anyway.
>
> OTOH other exceptions are correctly handled as usual
> >> say miao
> Could not find non-existent sub miao
> >> say $miao
> Scope not found for PAST::Var '$miao'
> >>
>
>
> Furthermore, notice that if the result of the operation is null
> nothing is printed (python-like behaviour) so for example the default
> language shell will have
>
> >> say 1;
> 1
> >> say "hello";
> "hello"
> >>
>
> All parrot and rakudo tests seem to pass, which means that probably
> there are no tests for this functionality at all.
>
> The patch respects the previous behaviour of special casing the PIR
> target so that it does not print anything else.
Sorry for the delay - this patch had stalled waiting for review due to a ticketing system
changeover, and in the meantime, no longer applies cleanly against parrot HEAD.
Can you rebase this patch and resubmit it to https://trac.parrot.org/ ? Hopefully we can
provide better turnaround next time.
Thanks again!
--
Will "Coke" Coleda
More information about the parrot-dev
mailing list