Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!cis.ohio-state.edu!math.ohio-state.edu!jussieu.fr!oleane!tank.news.pipex.net!pipex!news.sprintlink.net!uunet!in1.uu.net!olivea!charnel.ecst.csuchico.edu!csusac!csus.edu!netcom.com!vrotney
From: vrotney@netcom.com (William Paul Vrotney)
Subject: Re: Future of Lisp
In-Reply-To: tanksley@owl.csusm.edu's message of 28 Jul 1995 17:02:13 -0700
Message-ID: <vrotneyDCGx67.5wC@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <3ulpfn$m0p@hazel.Read.TASC.COM> <ZIGGY.95Jul26155006@montreux.ai.mit.edu> <3v776o$c3s@owl.csusm.edu> <19950727T063605Z@naggum.no> <3vbtq5$bs6@owl.csusm.edu>
Date: Sat, 29 Jul 1995 08:06:07 GMT
Lines: 42
Sender: vrotney@netcom.netcom.com

In article <3vbtq5$bs6@owl.csusm.edu> tanksley@owl.csusm.edu (Billy Tanksley) writes:
> 
> By the way, my main problem with Lisp's use of parenthesis arose from the 
> fact that I'm used to a language that uses no delimiters of any kind, 
> Forth.  Has anyone made a RPN Lisp?  That might be a good start for me.  
> Postscript is the closest I could find, and it's not close enough :).
> 

It's not possible unless you use, you guessed it, PARENTHESIS, since Common
Lisp allows variable argument number functions.  For example

        3 4 5 6 + *

is ambiguous, where as

        3 (4 5 6 +) *       or      3 4 (5 6 +) *    are almost ok

I say almost because the RPN expression

        3 4 +

could be interpreted as

        (progn (+ 3 4))  or  (progn 3 (+ 4)) or (progn 3 4 (+))

If you require parenthesis for non-atomic expressions then writing an RPN
Lisp interpreter is a short program in Lisp.  Something like

    (defun rpn-interpreter ()
      (labels ((rpn (exp) (if (atom exp) exp
                            (apply (symbol-function (car (last exp)))
                                   (mapcar #'rpn (cdr (reverse exp)))))))
        (loop (print (rpn (read))))))

You can play around with the REVERSE for non-first-last syntax.  I'll leave
the RPN compiler for you as an exercise.

--
William P. Vrotney - vrotney@netcom.com
-- 

William P. Vrotney - vrotney@netcom.com
