gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Disable a warning?


From: Jared Davis
Subject: Re: [Gcl-devel] Disable a warning?
Date: Thu, 12 Aug 2004 16:09:25 -0500
User-agent: Mozilla Thunderbird 0.7.1 (X11/20040715)

Basically I am using an external program to queue up commands for GCL from multiple external sources. The program then issues the commands one at a time, in the order they arrive. I would like to change the read/eval/print loop to support this. The problems I have with the current setup are:

1.  I'd like to be able to tell when GCL is ready for input, i.e., done
producing output.

2. If a command is incomplete, it will "hose" the session. For example, if program A sends "(defun f (x)" but provides no body for f, then GCL will wait for more input. If program B then has some request, e.g. (+ 1 2), the request will not be handled correctly. So, I'd like to give GCL the notion of "complete" and "incomplete" commands, and have
it simply print out a message about incomplete commands.

To address these problems I have implemented the following scheme: When read is invoked, it prints a ready-for-input character. When read encounters #!, it treats it as a special "end of command" marker and prints an error message, then recursively calls itself until a proper command is entered.

But of course to do this I have to redefine read, which gives me the warning message, and also my solution does not seem to work for the debugging loop. (It is also deficient in that it doens't address any of the other primitive read operations like read-char, but I'm frankly not sure what to do yet to handle those.)

I'd definitely like to find a better (and more portable) solution, but I'm not sure if there's an easier way around the problem...

Anyway, here's the code I'm using right now.

(defun throw-error (stream char arg)
  (throw 'end-of-command-exception 'end-of-command))

(set-dispatch-macro-character #\# #\! #'throw-error)

(defun new-read (&optional input-stream eof-error-p
                 eof-value recursive-p)
  (progn (format t *ready-for-input-string*)
         (let ((attempt (catch 'end-of-command-exception
                               (original-read input-stream eof-error-p
                                              eof-value recursive-p))))
           (if (eq attempt 'end-of-command)
               (progn (format t *end-of-command-string*)
                      (new-read input-stream eof-error-p
                                eof-value recursive-p))
             attempt))))

(setf (symbol-function 'original-read) (symbol-function 'read))
(setf (symbol-function 'read) (symbol-function 'new-read))


Thanks!

  Jared




reply via email to

[Prev in Thread] Current Thread [Next in Thread]