Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!news.duke.edu!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!pipex!uknet!festival!edcogsci!jeff
From: jeff@aiai.ed.ac.uk (Jeff Dalton)
Subject: Re: Error: Cannot open the file . with AKCL
Message-ID: <Cyx32u.88G@cogsci.ed.ac.uk>
Sender: usenet@cogsci.ed.ac.uk (C News Software)
Nntp-Posting-Host: bute-alter.aiai.ed.ac.uk
Organization: AIAI, University of Edinburgh, Scotland
References: <CysuyE.LIp@cs.ruu.nl> <39grnj$gqd@tools.near.net>
Date: Mon, 7 Nov 1994 21:44:54 GMT
Lines: 31

In article <39grnj$gqd@tools.near.net> barmar@nic.near.net (Barry Margolin) writes:
>In article <CysuyE.LIp@cs.ruu.nl> lucas@cs.ruu.nl (Peter Lucas) writes:
>>I am experiencing the problem with AKCL that after invoking
>>the AKCL interpreter from Unix, the newline char is not flushed.
>
>Try calling CLEAR-INPUT before READ-LINE.

Doesn't always work.  I've had to resort to this:

;;; Note that we have to deal with an annoying [A]KCL bug.  If you
;;; type in a form that READ can find the end of without looking at
;;; the first character after the form (eg, if you type a list or
;;; string as opposed to, say, a number or symbol), then the newline
;;; after the form stays in the input buffer and makes LISTEN return
;;; true.  CLEAR-INPUT doesn't clear it.  So we have to do it by hand.

(defun really-clear-whitespace (stream)
  (loop
    (let ((c (read-char-no-hang stream nil nil nil)))
      (cond ((null c)
	     (return))
	    ((not (whitespace-p c))
	     (unread-char c stream)
	     (return))))))

(defun whitespace-p (c)
  (member c '(#\space #\newline #\tab #\return) :test #'char=))

Jeff Dalton,
AI Applications Institute,                               J.Dalton@ed.ac.uk
Edinburgh University.
