# New Ticket Created by  "gabriele renzi" 
# Please include the string:  [perl #61088]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=61088 >


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.

Attachment: repl3.patch
Description: Binary data

Reply via email to