The examples look pretty cool, Grant. The try catch method seems to work for multi-line statements, but I have some questions about it. What if the user simply typos a single-line statement? Won’t the REPL assume it was multiline? Also, how will the user ever see the error message that goes along with their typo?
I’d almost like to go with a parsing approach where we count the number of opening and closing parens and curlies before we just try/catch and assume. Of course, all this applies to the script REPL.
Also, out of curiosity do other REPLs in the programming world output the variable type? It’s interesting, but I found it a bit distracting in the output-- especially since I already know what the data types are. If this is common in other REPLs, then just chalk it up to my inexperience with REPLs in general.
Regarding the tab completion, I actually noticed that too yesterday and made a mental note of it. The completor is a CFC being proxied as a Java class to the console reader object. It’s set in the system/util/ReaderFactory.cfc file.
Check out the API docs for the ConsoleReader class (We use JLine under the hood)
There are method in there for getting the list of completors, removing them, or adding them back in. We should minimally be able to remove the completor and add it back when we’re done kind of like how we handle the history files. Or, if there is actually a use for tab completion, we could write a script and tag REPL completor.
As far as inserting special characters, I allow new lines in parameter values via \n and I think I have a ticket in to support tabs with \t. That’s a bit of a slippery slope to start down though since you have to start parsing all input and then having escape chars for your escape chars… You can see how the command parser works a bit by looking in system/util/Parser.cfc.
ColdBox Platform Evangelist
Ortus Solutions, Corp
ColdBox Platform: http://www.coldbox.org