From: Joan M. Garcia
Subject: Read macros for user interface --- asking for advice
Date: 
Message-ID: <uzna6d0jq.fsf@sa-tuna.net>
I've written a small program for taking and managing text
notes.  The user interface requirements are so far pretty
trivial: just need ways to ask for a list of notes,
display/delete/modify a note, call emacs to input a new
note, and save/restore them.  Calling the corresponding
functions from ilisp is almost acceptable.  I've considered
several possibilities for speeding up the interaction,
including a function that listens to the keyboard and calls
(list-notes) when the user types l, and a stack-based
postscript-style language that would allow the user to
define complex manipulations.  Then I thought about leaving
the manipulations to Lisp, and defining read macros that
call the functions and save typing.  I quickly went ahead to
hurt myself defining things like

#L  (lists notes)
#D[int]  (displays note given its id)
etc.

This works nicely, except that the modifications to the lisp
reader were large enough to break the load of compiled files
in clisp.  Then I thought about using another dispatch
character, like .L .D[int] but I suspect that would also
hurt me pretty nicely, even though I don't know how much
(would it render me unable to input floats?).  My latest
idea is to modify (a local copy of) the readtable, so that
typing l calls (list-notes), and so on.  But this would
render the readtable pretty much useless for reading actual
lisp code, so maybe it's not such a good idea after all.  I
would still be able to use arithmetic functions, though.

Any suggestions?  Am I way off?  Should I stick to the
na"ive character reader?

jm

From: Pascal Costanza
Subject: Re: Read macros for user interface --- asking for advice
Date: 
Message-ID: <c3s5jc$l78$1@newsreader2.netcologne.de>
Joan M. Garcia wrote:
> Any suggestions?  Am I way off?  Should I stick to the
> na"ive character reader?

Two things:

+ If you are worried about Lisp sources, you are pretty safe by placing 
the following at the top of a file.

(eval-when (:compile-toplevel :load-toplevel :execute)
   (setq *readtable* (copy-readtable nil)))

This ensures that the rest of the file is read with the standard readtable.

COMPILE-FILE and LOAD are specified to reset the *readtable* to whatever 
it was before a file is compiled or loaded. So you can switch on your 
reader extensions for the listener but still load Lisp sources as before.

+ If you're still worried about not being able to use standard Lisp 
syntax in the listener, you may start another listener in a different 
thread. Since *readtable* is a special variable and each thread has 
their own bindings for special variables in most multi-threaded CL 
implementations, you should be able to easily create special-purpose 
listeners with their own syntax alongside the standard listener.


I hope this helps.


Pascal

-- 
1st European Lisp and Scheme Workshop
June 13 - Oslo, Norway - co-located with ECOOP 2004
http://www.cs.uni-bonn.de/~costanza/lisp-ecoop/
From: Adam Warner
Subject: Re: Read macros for user interface --- asking for advice
Date: 
Message-ID: <pan.2004.03.24.11.52.38.388937@consulting.net.nz>
Hi Joan M. Garcia,

> #L  (lists notes)
> #D[int]  (displays note given its id)
> etc.
> 
> This works nicely, except that the modifications to the lisp
> reader were large enough to break the load of compiled files
> in clisp.  Then I thought about using another dispatch
> character, like .L .D[int] but I suspect that would also
> hurt me pretty nicely, even though I don't know how much
> (would it render me unable to input floats?).

Consider using #\! as a dispatching macro character instead of #\#.
#\! is one of the six macro characters reserved for the programmer.
!L, !D, etc. should look and work fine.

Refer 2.1.4 in the HyperSpec for the characters explicitly reserved for
the programmer: { } [ ] ! ?

Regards,
Adam