Console Transcript Replay: I Want It

I'm moving this from a post I made that was tied up with suggestions about changing the prompt away from >> to make it more obviously taken as an asymmetric delimiter. This is an interesting feature which can be discussed in its own right...


Let's imagine someone tells you they've set x: 1, and then have the following code:

>> x + 2
== 3

>> print "hi"
hi

Try pasting that today, say, in Red and you will get:

>>      >> x + 2
*** Script Error: >> operator is missing an argument
*** Where: catch
*** Stack:  

>>      == 3
*** Script Error: == operator is missing an argument
*** Where: catch
*** Stack:  

>> 
>>     >> print "hi"
*** Script Error: >> operator is missing an argument
*** Where: catch
*** Stack:  

>>     hi
*** Script Error: hi has no value
*** Where: catch
*** Stack:  

But What If...

...imagine you could go on a website, drag across someone's transcript, and paste it right into your console unedited and have it run.

What I'm talking about is knowing that you are receiving a paste (either by virtue of an API that tells you, or just noticing that the rate at which lines are coming in is faster than a human types...a heuristic I have been meaning to implement so that lines are batched instead of intermixing with the output). And really being able to just paste a console transcript whole cloth, but have it respond by outputting its own complementary transcript.

So now let's say your transcript looked like:

>> x + 2
== 3

>> print "hi"
hi

So if you pasted it into an environment where you'd said x: 10 it would take the data one line at a time, and >> would kick it over into a replay mode

>> x: 10
== 10

>> ; here you do the paste, it sees the >> and kicks over

[[ TRANSCRIPT PASTE DETECTED ]]
( to disable, see http://rebol.info/disable-transcript-paste-detection )

; >> x + 2
; == 3
;
; >> print "hi"
; == hi

[[ REPLAYING TRANSCRIPT ]]

>> x + 2
== 12

>> print "hi"
hi

...Heuristics, hmmm... :face_with_monocle:

If we keep the current indicators for prompts, e.g. >> and == with ** for errors, then we'd be making heuristic decisions here...since these are all things you can legally use elsewhere.

== is in common use today as an operator, though it rarely appears at the beginning of a line. I intend it to not be an operator, but a divider of some kind. So it actually be contentious, because although == doesn't appear at the start of a line today, it would as a divider. So maybe plain equals, just off by one space?

>> x + 2
 = 12

Parity just looks confusing, don't think anyone would get used to it:

>> x + 2
<< 12

Anyway, now that I've outlined this feature, I want it yesterday. The value of such a feature may exceed the value of dedicating <<x>> as some new lexical type for MAP! or similar.

2 Likes

It could also be interesting to have this work like a test, with an indication which value was in the transcript, and which value was computed in the session.