[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help in writing infix macro in CL.
- To: sridhar%tekecs%tektronix.csnet@RELAY.CS.NET
- Subject: Re: Help in writing infix macro in CL.
- From: NGALL@G.BBN.COM
- Date: Tue, 06 May 1986 14:17:00 -0000
- Cc: common-lisp@SU-AI.ARPA
- In-reply-to: <8605052327.AA21173@tekecs.TEK>
- Sender: NGALL@G.BBN.COM
Date: Mon, 5 May 86 16:27:46 PDT
From: "S. Sridhar" <sridhar%tekecs%tektronix.csnet@CSNET-RELAY.ARPA>
Subject: Help in writing infix macro in CL.
Is there a way to do the following using the reader macro functions
of CLtL ?
I want to have a reader macro that translates
(a + b) to (+ a b). How can I remember the lisp object that was read
before the macro character #\+.
I would appreciate some pointers.
As Scott pointed out, there is no way in CL to access what has been
read prior to the execution of a read-macro. To do what you want, you
would have to redefine the read-macro for #\( to save the elements
seen so far in a list that is manipulatable via a global variable. A
less ambitious approach might be to use [...] around infix
expressions; then you wouldn't have to worry about breaking (...).