18.3 Slave Lisps

  • 18.3.1 The Current Slave
  • 18.3.2 Asynchronous Operation Queuing
  • 18.3.3 Synchronous Operation Queuing
  • Some implementations of Hemlock feature the ability to manage multiple slave Lisps, each connected to one editor Lisp. The routines discussed here spawn slaves, send evaluation and compilation requests, return the current server, etc. This is very powerful because without it you can lose your editing state when code you are developing causes a fatal error in Lisp. [annotate]

    The routines described in this section are best suited for creating editor commands that interact with slave Lisps, but in the past users implemented several independent Lisps as nodes communicating via these functions. There is a better level on which to write such code that avoids the extra effort these routines take for the editor's sake. See the CMU Common Lisp User's Manual for the remote and wire packages. [annotate]

    18.3.1 The Current Slave

    There is a slave-information structure that these return which is suitable for passing to the routines described in the following subsections. [annotate]

    create-slave  &optional name [Function]
              

    This creates a slave that tries to connect to the editor. When the slave connects to the editor, this returns a slave-information structure, and the interactive buffer is the buffer named name. This generates a name if name is nil. In case the slave never connects, this will eventually timeout and signal an editor-error. [annotate]

    [annotate]

    get-current-eval-server  &optional errorp [Function]
    Current Eval Server  (initial value ) [Variable]
              

    This returns the server-information for the Current Eval Server after making sure it is valid. Of course, a slave Lisp can die at anytime. If this variable is nil, and errorp is non-nil, then this signals an editor-error; otherwise, it tries to make a new slave. If there is no current eval server, then this tries to make a new slave, prompting the user based on a few variables (see the Hemlock User's Manual). [annotate]

    [annotate]

    get-current-compile-server   [Function]
    Current Compile Server  (initial value ) [Variable]
              

    This returns the server-information for the Current Compile Server after making sure it is valid. This may return nil. Since multiple slaves may exist, it is convenient to use one for developing code and one for compiling files. The compilation commands that use slave Lisps prefer to use the current compile server but will fall back on the current eval server when necessary. Typically, users only have separate compile servers when the slave Lisp can live on a separate workstation to save cycles on the editor machine, and the Hemlock commands only use this for compiling files. [annotate]

    [annotate]

    18.3.2 Asynchronous Operation Queuing

    The routines in this section queue requests with an eval server. Requests are always satisfied in order, but these do not wait for notification that the operation actually happened. Because of this, the user can continue editing while his evaluation or compilation occurs. Note, these usually execute in the slave immediately, but if the interactive buffer connected to the slave is waiting for a form to return a value, the operation requested must wait until the slave is free again. [annotate]

    string-eval  string [Function]
    region-eval  region [Function]
    region-compile  region [Function]
              

    string-eval queues the evaluation of the form read from string on eval server server. Server defaults to the result of get-current-server, and string is a simple-string. The evaluation occurs with package bound in the slave to the package named by package, which defaults to Current Package or the empty string; the empty string indicates that the slave should evaluate the form in its current package. The slave reads the form in string within this context as well. Context is a string to use when reporting start and end notifications in the Echo Area buffer; it defaults to the concatenation of "evaluation of " and string. [annotate]

    region-eval is the same as string-eval, but context defaults differently. If the user leaves this unsupplied, then it becomes a string involving part of the first line of region. [annotate]

    region-compile is the same as the above. Server defaults the same; it does not default to get-current-compile-server since this compiles the region into the slave Lisp's environment, to affect what you are currently working on. [annotate]

    [annotate]

    file-compile  file [Function]
    Remote Compile File  (initial value nil) [Variable]
              

    This compiles file in a slave Lisp. When output-file is t, this uses a temporary output file that is publicly writable in case the client is on another machine, which allows for file systems that do not permit remote write access. This renames the temporary file to the appropriate binary name or deletes it after compilation. Setting Remote Compile File to nil, inhibits this. If output-file is non-nil and not t, then it is the name of the binary file to write. The compilation occurs with package bound in the slave to the package named by package, which defaults to Current Package or the empty string; the empty string indicates that the slave should evaluate the form in its current package. Error-file is the file in which to record compiler output, and a nil value inhibits this file's creation. Load indicates whether to load the resulting binary file, defaults to nil. Server defaults to get-current-compile-server, but if this returns nil, then server defaults to get-current-server. [annotate]

    [annotate]

    18.3.3 Synchronous Operation Queuing

    The routines in this section queue requests with an eval server and wait for confirmation that the evaluation actually occurred. Because of this, the user cannot continue editing while the slave executes the request. Note, these usually execute in the slave immediately, but if the interactive buffer connected to the slave is waiting for a form to return a value, the operation requested must wait until the slave is free again. [annotate]

    eval-form-in-server  server-info string &optional package [Function]
              

    This function queues the evaluation of a form in the server associated with server-info and waits for the results. The server read's the form from string with package bound to the package named by package. This returns the results from the slave Lisp in a list of string values. You can read from the strings or simply display them depending on the print'ing of the evaluation results. [annotate]

    Package defaults to Current Package. If this is nil, the server uses the value of package in the server. [annotate]

    While the slave executes the form, it binds terminal-io to a stream that signals errors when read from and dumps output to a bit-bucket. This prevents the editor and slave from dead locking by waiting for each other to reply. [annotate]

    [annotate]

    eval-form-in-server-1  server-info string &optional package [Function]
              

    This function calls eval-form-in-server and read's the result in the first string it returns. This result must be read'able in the editor's Lisp. [annotate]

    [annotate]