Extending Python Syntax with @

David MacQuigg dmq at gain.com
Thu Mar 11 15:05:07 EST 2004


On Thu, 11 Mar 2004 14:50:57 +0000, Peter Hickman
<peter at semantico.com> wrote:

>If what motivates you is the 'ultimate language' and think you can get 
>closer to it by adding special characters then you are going to be very 
>disappointed. The history of computing is littered with 'ultimate 
>languages' that have had much more thought put into them than adding 
>special characters to an existing language (C++ comes to mind) and they 
>all have in common the fact that they failed.

Perl seems to be a better example of too much syntax.

>To be fair C++ was never touted as an 'ultimate language' but you get 
>the picture.
>
>If you feel python has a significant flaw then say what it is and how 
>you believe it would best be addressed. Using @ as a special character 
>is just adding sugar to the syntax.

It's not a single flaw.  In fact I can't imagine a single flaw that
would justify adding a special symbol.  It only makes sense if adding
the symbol *improves* consistency by reducing the number of syntactic
variations, compared to adding each new feature with a *different*
syntax or unique keyword.

If someone new to Python saw a function with '@return' instead of
'return', it would be pretty easy to remember this has something to do
with efficiency, just think of it as a normal function until you start
writing your own code.

There is an optimum balance between too much syntax and too little.  I
think Python is pretty close to that optimum.  There are a few things
I would eliminate, and a few things I would add.  Same with Ruby.  I
like their use of the @ symbol, but I can't see the advantage of their
cryptic 'code blocks' over a normal Python function.  I don't like
their subtle distinction between single and double-quoted strings.  

Much of this is just personal preference, but in some cases you can
see a real advantage.  I like their simple but powerful string
methods.  You can put a lot on one line without sacrificing clarity.
See http://userlinux.com/cgi-bin/wiki.pl?RubyPython for details.  I
think we can learn some things from Ruby, which after all, was
developed after a few years of learning from Python.

-- Dave




More information about the Python-list mailing list