Python syntax in Lisp and Scheme

prunesquallor at comcast.net prunesquallor at comcast.net
Tue Oct 7 20:01:15 EDT 2003


Pascal Bourguignon <spam at thalassa.informatimago.com> writes:

> Most  probably, you  would write  a  macro named  WITH-INFIX and  thus
> automatically scope the infix part:
>
>     (with-infix  1 / x + 1 / ( x ^ 3 ) +  1 / ( x ^ 5 ) )
>
> and if you write it well:
>     
>     (with-infix
>       if a = b then format t "equal ~D~%" a ;  
>         else format t "diff ~D /= ~D~%" a b ; endif ;
>       for i = 1 to 10 ; print i ; next i )

CGOL is an Algol-like syntax for MacLisp that was designed by Vaughn
Pratt.  I believe it has been ported to CL.

    ABSTRACT

            MACLISP programmers who feel comfortable with ALGOL-like
    notation, that is, an algebraic style in which one might write a
    matrix multiply routine as

            for i in 1 to n do
              for k in 1 to n do
                (ac := 0;
                 for j in 1 to n do
                    ac := ac + a(i,j)*b(j,k);
                 c(i,k) := ac)

    can now write LISP programs in just such a notation.  This notation is
    essentially transparent to the MACLISP system, and files containing
    CGOL code (possibly mixed in with standard code) can be read by the
    interpreter and compiled by the compiler just as though they were
    written in straight LISP notation. 


It has never caught on, though.


> I'll tell you the secret: yes  there are alot of parethesis. This is a
> price  all  lispers  pay  for  greater benefits.   It  gives  us  such
> advantages that we gladly pay the price.

Excerpts from real C header files:

#define FromHex(n) (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
#define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + (FromHex(HIBYTE(LOWORD(fcc))))))
#define ToHex(n) ((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
#define MAKEAVICKID(tcc,stream)  MAKELONG((ToHex((stream) & 0x0f) << 8) | (ToHex(((stream) & 0xf0) >> 4)),tcc)

#define va_arg(AP, TYPE)      \
 (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
  *((TYPE *) (void *) ((char *) (AP)     \
         - ((sizeof (TYPE) < __va_rounded_size (char) \
      ? sizeof (TYPE) : __va_rounded_size (TYPE))))))

#define PLAUSIBLE_BLOCK_START_P(addr, offset)    \
((*((format_word *)       \
    (((char *) (addr)) + ((offset) - (sizeof (format_word)))))) == \
   ((BYTE_OFFSET_TO_OFFSET_WORD(offset))))





More information about the Python-list mailing list