REPL Enhancement

Hello all,

I’ve been playing around with the CommandBox REPL and noticed something that I think could be improved.

In other REPL’s that I’ve used, when you enter an expression, such as “1 + 2;”, it will evaluate the expression and return the value 3. Our REPL doesn’t do this currently.

To achieve the desired result, you have to enter something like writeOutput(1+2); which is kind of lame.

I have made some modifications so that the REPL tries to evaluate the most recent expression and output to the screen like so. (see attached image).

What are your guys thoughts on this? If you like the changes, I’ll create a pull request.




Yes, that’s something I’ve noticed too. Most REPLs automatically print any value output by the expression that was evaluated.

The original REPL Denny had, passed everything through the evaluate function, though I don’t think that would allow you to do more complex statements.

Generally speaking though, we’d be interested in any enhancement ideas for the REPL. Right now it is pretty rudimentary.

The changes I implemented are using the evaluate function also, so for the moment it only works with simple expressions. I’d like to see the REPL be able to handle multi-line complex expressions also. I’ll spend some time on this and see what I can come up with.

Yeah, I’d wondered a bit myself on how to do that. My understanding is that you should be able to type a multi-line statement, most REPLs will recognise that and wait until you’ve completed it to run it. For instance:

CFSCRIPT-REPL: if( 1 > 2 ) {

CFSCRIPT-REPL: writeOutput( ‘yes’ );


CFSCRIPT-REPL: writeOutput( ‘no’ );



The problem I have is being able to parse the input from the user and knowing when the statement is complete without basically rewriting the CFML parser.