interrupting REPL ILoop programatically

i have a wrapper for the scala REPL api (ILoop etc...) using the refactored 2.9.x classes.

this works well.

as this is a tool shipped to users, it is possible the user will type something like :

while(-1 < 1) {}

how can the user break from the currentlly executing code?

other posts talk about

<ctrl> + <c> 

kind of working on some platforms under appropriate key bindings.

inspecting the scala REPL api and any available docs, it isnt obious how to actually implement this.



Check out how the Scala REPL does it in the file ILoopInit.scala. There the following signal interrupt handler is installed,

  protected def installSigIntHandler() {
    // ....
    SignalManager("INT") = {
      if (intp == null || intp.lineManager == null)
      else if (intp.lineManager.running)
      // ...

Note that the field intp: IMain is defined in class ILoop, which is the self-type of ILoopInit.

To summarize: in your SIGINT handler you can interrupt the REPL with intp.lineManager.cancel.

Need Your Help

External script files not loaded in meteorjs

javascript meteor

I am just starting in meteor. I have create 4 folders, client, server , public and both. I have put some js files that my app depends upon in the public folder. But when I load my app and check the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.