Search                        Top                                  Index
HELP POPTOLISP                                  Jon Cunningham, Oct 1984

This file provides a list of sample translations from Pop-11 to Poplog
Common Lisp. It is intended as quick reference reminder for Pop-11 users
learning Lisp (or Lisp users learning Pop-11), and should be used in
conjunction with a more detailed source. For information on how to run
Lisp, read HELP * CLISP. HELP * LISPVED explains how to prepare Lisp
programs using the VED editor. Details of the Lisp/Pop-11 mixed language
interface can be found in HELP * POPLISP.


         CONTENTS - (Use <ENTER> g to access required sections)

  1   Things to Avoid
  2   Comments
  3   Upper and Lower Case Letters
  4   Quotes
  5   Translation Summary


-----------------------------------------------------------------------
1  Things to Avoid
-----------------------------------------------------------------------

The characters # . , @ and : all have special meanings in Common Lisp.
Don't use them unless you know what you're doing.


-----------------------------------------------------------------------
2  Comments
-----------------------------------------------------------------------

The Lisp end-of-line comment character is the same as Pop-11's, (the
semi-colon ";"), so you can comment programs in exactly the same way.
Bracketed comments are notated using #| and |#.


-----------------------------------------------------------------------
3  Upper and Lower Case Letters
-----------------------------------------------------------------------

Remember that lower case input is automatically translated to upper case
(except within a string). Thus

    == 'hello
    == 'HELLO
    == 'Hello
    == 'helLO

are all equivalent.


-----------------------------------------------------------------------
4  Quotes
-----------------------------------------------------------------------

The quote notation, has two forms: forward quote ', and back quote `.
Although the forward quote is the "standard" quote, which you will see
in text books, only the back-quote form allows the use of "comma"
notation. This is like "up-arrow" in Pop-11: examples are shown in the
section below. There are also other more subtle differences between
forward and back quote.


-----------------------------------------------------------------------
5  Translation Summary
-----------------------------------------------------------------------

Here are some examples of functionally similar Pop-11 and Lisp
expressions:

         Pop-11                            Lisp
  ----------------------            ---------------------

  proc(arg1, arg2, arg3)    -->     (proc arg1 arg2 arg3)

                  proc()    -->     (proc)

                      []    -->     nil

                    true    -->     t

                  a :: b    -->     (cons a b)

                  a <> b    -->     (append a b)

                   a = b    -->     (equalp a b)

                  a == b    -->     (eq a b)

                  a = []    -->     (null a)

                   a + b    -->     (+ a b)

                  x -> y    -->     (setq y x)

              'Hi there'    -->     "Hi there"

                   "oof"    -->     'oof

               [foo baz]    -->     '(foo baz)

    [% foo, baz, grum %]    -->     (list foo baz grum)

        [% "foo", baz %]    -->     (list 'foo baz)

              [foo ^baz]    -->     `(foo ,baz)

        [foo ^^baz grum]    -->     `(foo ,@baz grum)

                hd(list)    -->     (car list)

                tl(list)    -->     (cdr list)

        hd(tl(tl(list)))    -->     (caddr list)

               {foo baz}    -->     #(foo baz)

        {% "foo", baz %}    -->     (vector 'foo baz)

              {foo ^baz}    -->     `#(foo ,baz)


   if c then s                 -->  (if c s)
   endif

   if c then s                 -->  (if c s s1)
   else s1
   endif

   if c1 then s1               -->  (cond
   elseif c2 then s2                    (c1 s1)
   elseif c3 then s3                    (c2 s2)
   else s4                              (c3 s3)
   endif                                (t s4))

   until c do s enduntil    -->     (loop until c do s)

   while c do s endwhile    -->     (loop while c do s)

   for item in list do      -->     (dolist (item list) s)
      s
   endfor

   [% for item in list do   -->     (loop for item in list
        s                            collect s)
   endfor %]

   for i from 0 to n do     -->     (dotimes (i n) s)
       s
   endfor

   define greet(name);      -->     (defun greet (name)
       [hello ^name] =>                 (print `(hello ,name)))
   enddefine;



--- C.all/lisp/help/poptolisp
--- Copyright University of Sussex 1987. All rights reserved.