Extending Python Syntax with @

David MacQuigg dmq at gain.com
Thu Mar 11 11:35:04 EST 2004


On Thu, 11 Mar 2004 13:15:39 +0100, Peter Maas
<fpetermaas at netscape.net> wrote:

>David MacQuigg schrieb:
>> Seems like we need a simple way to extend Python syntax that doesn't
>> break existing syntax or clash with any other syntax in Python,
>[...]
>> @x,y:x*x+y*y    -- anonymous function
>
>Advantage of your proposal:
>
>- easy to extend the language without breaking existing code.
>
>Disadvantages of your proposal:
>
>- The advantage is also a disadvantage: a lowered barrier for
>   new semantics could bloat the language definition. Python's
>   strength is that it has *few* concepts that are usable in *many*
>   places. This could be compromised by your proposal.

This is actually a separate issue.  Adding a few @ mods to selected
statements does not mean that users can add their own.

>- Python is a readable language. lambda says "function literal",
>   yield says "generator", @ just says "different". Python would
>   be less readable if this notation would be adopted.

Readability, in this case, is in the eye of the beholder.  'lambda' to
me says 'wavelength', which I know has nothing to do with programming.
I suspect many users are like me, not enough computer science
background to know that lambda means 'function literal'.

'yield' is a little closer to the intent, but again, to most new users
it probably means something more like 'give way' or 'acquiesce', the
opposite of 'resist'.  If you had never seen 'yield' used as it is now
in Python, and your first encounter with generator functions was when
you saw @return, would you not think "Ah yes, a modified return.", and
would that not be closer to reality than whatever you might associate
with the word 'yield'?

@ would never be used alone.  Like the '\' symbol used as an escape,
its meaning beyond 'different' is seen by its context.

Again, these examples are to illustrate a discussion on syntax, not to
urge changing what has already been done.  ( Althugh I just learned
from another part of this thread that 'lambda' *is* going to be
deprecated !! )

I almost wish Python had adopted the Unix philosphy of using short,
meaningless words for primitives.  That would have avoided the problem
we are having now with 'print'.  Words like 'cat' and 'grep' acquire
their own meaning, not dependent on previous meanings in English.

-- Dave




More information about the Python-list mailing list