[Python-Dev] python symbolizition

2013-06-14 Thread Pynix Wang
1.lambda expression

c#
a.(x, y) => x == y
b.() => SomeMethod()

ruby:
 -> {|msg| puts msg}

python can use c# like and remove "lambda" keyword.

2.global variable

ruby
$glo_var

python can use $ or @ or another and remove "global".
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] add new lambda syntax

2013-06-28 Thread Pynix Wang
I want use coffeescript function syntax to write python lambda expression
so I modified the Grammar file.

```
atom: ('(' [yield_expr|testlist_comp|vararglist] ')' |
   '[' [testlist_comp] ']' |
   '{' [dictorsetmaker] '}' |
   NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME | '->' text
```

but when I write
```
(x,y=1)->x+y
```
the parser doesn't go into vararglist.

any help?
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] add new lambda syntax

2013-06-29 Thread Pynix Wang
http://aruld.info/lambda-expressions-in-java-8-adopts-c-style-syntax/

Lambda expressions in Java 8 adopts C# style syntax.


On Sat, Jun 29, 2013 at 1:39 AM, Thomas Wouters  wrote:

>
>
>
> On Fri, Jun 28, 2013 at 7:01 PM, Amaury Forgeot d'Arc 
> wrote:
>
>> 2013/6/28 Pynix Wang 
>>
>>> I want use coffeescript function syntax to write python lambda
>>> expression so I modified the Grammar file.
>>>
>>> ```
>>> atom: ('(' [yield_expr|testlist_comp|vararglist] ')' |
>>>'[' [testlist_comp] ']' |
>>>'{' [dictorsetmaker] '}' |
>>>NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')
>>> trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME | '->' text
>>> ```
>>>
>>> but when I write
>>> ```
>>> (x,y=1)->x+y
>>> ```
>>> the parser doesn't go into vararglist.
>>>
>>
>> This grammar is not LL(1) anymore (it's probably LALR now)
>> when seeing "x", it has the choice between testlist_comp and vararglist,
>> and the first one is picked.
>> Python's parser generator only supports LL(1) grammars.
>>
>
> Indeed. You may be able to make this work, but you'd have to fold the bits
> of vararglist you need into testlist_comp, then reject invalid syntax that
> matches the grammar (like "(x=expr for ...)" or "((x+1)=expr)" or
> "(*foo=1)") in the compiler. Something like (untested):
>
> testlist_comp: (test|star_expr) ['=' test]( comp_for | (','
> (test|star_expr) ['=' test])* [','] )
>
> --
> Thomas Wouters 
>
> Hi! I'm an email virus! Think twice before sending your email to help me
> spread!
>
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com