Re: Python syntax in Lisp and Scheme

From: Ed Avis (ed_at_membled.com)
Date: 10/04/03


Date: 04 Oct 2003 20:46:26 +0100

mike420@ziplip.com writes:

>I'd like to know if it may be possible to add a powerful macro system
>to Python, while keeping its amazing syntax,

I fear it would not be. I can't say for certain but I found that the
syntax rules out nesting statements inside expressions (without adding
some kind of explicit bracketing, which rather defeats the point of
Python syntax) and you might run into similar difficulties if adding
macros. It's a very clean syntax (well, with a few anomalies) but
this is at the price of a rigid separation between statements and
expressions, which doesn't fit well with the Lisp-like way of doing
things.

Myself I rather like the option chosen by Haskell, to define an
indentation-based syntax which is equivalent to one with bracketing,
and let you choose either. You might do better to add a new syntax to
Lisp than to add macro capabilities to Python. Dylan is one Lisp
derivative with a slightly more Algol-like syntax, heh, Logo is
another; GNU proposed some thing called 'CTAX' which was a C-like
syntax for Guile Scheme, I don't know if it is usable.

If the indentation thing appeals, maybe you could preprocess Lisp
adding a new kind of bracket - say (: - which closes at the next line
of code on the same indentation level. Eg

    (: hello
       there
    (goodbye)

would be equivalent to

    (hello
     there)
    (goodbye)

I dunno, this has probably already been done.

-- 
Ed Avis <ed@membled.com>


Relevant Pages

  • Re: A decorator syntax not yet mentioned (I think!)
    ... Because to me it doesn't *act* like normal Python. ... except for the few that are based on indentation ... It seems like we both agree that the @pie syntax doesn't ...
    (comp.lang.python)
  • Re: which lisp book ?
    ... what's so common between python and lisp? ... coming from a Python background. ... They're both "practical" languages which, ... syntax differences. ...
    (comp.lang.lisp)
  • Re: Unification of Methods and Functions
    ... >would have the greatest concentration of unbound method use (my reasoning was ... staticmethod syntax is relatively new, and there is a long tradition ... in Python of using various alternatives to static methods. ...
    (comp.lang.python)
  • Re: Unification of Methods and Functions
    ... Moving them outside the ... inside and add the 'staticmethod' wrapper. ... and clients, who don't have time to get proficient in Python, and only ... That is one benefit of the proposed syntax. ...
    (comp.lang.python)
  • Re: - E04 - Leadership! Google, Guido van Rossum, PSF
    ... * BS in Computer Science or equivalent experience. ... you seem to know python. ... is a syntax trifle. ... sure to note the reciprocal "LIMITATION: ...
    (comp.lang.python)