1

If you run a script in Rebol and say something like print {Hello}, you end up calling the system version of PRINT

>> bind? 'print
== make object! [
    system: make object! [
        product: 'core
        version: 2.101.0.2.5
        build: 22-Jan-2013/2:44:29
        platform: [
            Macintosh osx-x86
        ]
        license: {Copyright 2012 REB....

Let's say I had a script %repl-context.r and it defined a context where PRINT did something else. Is there a way to ask the REPL to interactively run within that context, for several consecutive commands...?

2 Answers2

2

I'm not exactly certain of the purpose, but you could subvert the console with your own input/output process with a managed loop:

while [not find ["q" "quit"] command: ask "my-prompt> "][
    result: do bind load command 'my-context
    if value? result [print ["==" mold result]]
    ()
]

I use this method with my HTTP Console for R2.

Another possibility is digging into the workings of the system/ports/input port.

rgchris
  • 3,698
  • 19
  • 19
  • I was thinking of it in terms of implementation of a [REPL for Reblis](https://trello.com/c/WiQ5lSXM). Your idea works at a basic level, but doesn't necessarily inherit the trickery of the standard Rebol console for things like editing multi-line input... or handling Ctrl-C... that sort of thing. – HostileFork says dont trust SE May 17 '13 at 01:07
2

There is a common repl console wrapper around to handle I/o redirects for StdIn StdOut.

I often use rlwrap from http://utopia.knoware.nl/~hlub/rlwrap/#rlwrap

It uses GNU readline lib

  • Accepting as this is about the only answer possible at this time...and a few more points never hurt anyone, go check out [StackOverflow Rebol/Red chat](http://chat.stackoverflow.com/rooms/291/rebol-and-red) :-) – HostileFork says dont trust SE May 08 '14 at 23:26