Re: Proposal for new minor syntax

2015-04-09 Thread Antoon Pardon
On 03/28/2015 11:43 AM, Steven D'Aprano wrote: > On Sat, 28 Mar 2015 08:53 pm, Steven D'Aprano wrote: > > >> It saves typing. It might even allow a micro-optimization in the generated >> bytecode (see below). > Oops, I forgot to include the "see below" bit. > > Comparing > > a = a.spam() > > a .=

Re: Proposal for new minor syntax

2015-04-08 Thread Giorgos Tzampanakis
On 2015-03-28, Rustom Mody wrote: > Dunno if related... > One thing that is a bit laborious in python are object initializers: > > self.attr1 = field1 > self.attr2 = field2 Vim's "visual block" feature is your friend in such cases... Pretty sure that other editors have something equivalent, t

Re: Proposal for new minor syntax

2015-03-28 Thread Rustom Mody
On Sunday, March 29, 2015 at 9:47:00 AM UTC+5:30, Ian wrote: > On Sat, Mar 28, 2015 at 9:05 AM, Mario Figueiredo wrote: > > Neiter the language. The dot symbol is a delimiter in the python > > grammar. Not an operator. And also defined as a delimiter in the > > official documentation, right after o

Re: Proposal for new minor syntax

2015-03-28 Thread Ian Kelly
On Sat, Mar 28, 2015 at 9:05 AM, Mario Figueiredo wrote: > Neiter the language. The dot symbol is a delimiter in the python > grammar. Not an operator. And also defined as a delimiter in the > official documentation, right after operators. What does it matter? How '.' is lexed when it appears on

Proposal for new minor syntax

2015-03-28 Thread Sayth
Sounds like you want to implement nim special dot syntax in python. http://nim-lang.org/manual.html#special-operators -- https://mail.python.org/mailman/listinfo/python-list

Re: VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-28 Thread Rustom Mody
On Saturday, March 28, 2015 at 9:51:50 PM UTC+5:30, Rustom Mody wrote: > So if the VB model is followed, it is purely a syntactic (ie not type-related) > question whether an identifier is an adorned variable or an attribute of > something else. The preceding dot is the disambiguator. Uh... UN-ado

Re: VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-28 Thread Rustom Mody
On Saturday, March 28, 2015 at 11:56:39 AM UTC+5:30, Steven D'Aprano wrote: > On Sat, 28 Mar 2015 03:18 pm, Rustom Mody wrote: > > > One thing that is a bit laborious in python are object initializers: > > > > self.attr1 = field1 > > self.attr2 = field2 > > > > In VB one can do: > > > > with se

Re: Proposal for new minor syntax

2015-03-28 Thread Mario Figueiredo
On Sat, 28 Mar 2015 13:38:20 +, BartC wrote: > >(I'm not sure how this all applies to the loop_node.next example, but >even here I don't count the "." as an operator, but syntax. Neiter the language. The dot symbol is a delimiter in the python grammar. Not an operator. And also defined as a

Re: VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-28 Thread Mark Lawrence
On 28/03/2015 12:58, Steven D'Aprano wrote: On Sat, 28 Mar 2015 11:26 pm, Mark Lawrence wrote: On 28/03/2015 06:26, Steven D'Aprano wrote: Pascal is another language with a construct like that, and there's a FAQ for it: https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-w

Re: Proposal for new minor syntax

2015-03-28 Thread BartC
On 28/03/2015 09:53, Steven D'Aprano wrote: On Sat, 28 Mar 2015 10:08 am, BartC wrote: An alternate syntax might be: hello = .string() That should have been .strip() loop_node =. next Why propose that? Every other augmented assignment has the operator on the left hand side of the

Re: VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-28 Thread Steven D'Aprano
On Sat, 28 Mar 2015 11:26 pm, Mark Lawrence wrote: > On 28/03/2015 06:26, Steven D'Aprano wrote: >>Pascal is another language with a construct like that, and there's a FAQ >>for it: >> >> https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-with-statement-for-attribute-assignments

Re: VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-28 Thread Mark Lawrence
On 28/03/2015 06:26, Steven D'Aprano wrote: On Sat, 28 Mar 2015 03:18 pm, Rustom Mody wrote: One thing that is a bit laborious in python are object initializers: self.attr1 = field1 self.attr2 = field2 In VB one can do: with self .attr1 = field1 .attr2 = field2 (or something like that -- do

Re: Proposal for new minor syntax

2015-03-28 Thread Steven D'Aprano
On Sat, 28 Mar 2015 08:53 pm, Steven D'Aprano wrote: > It saves typing. It might even allow a micro-optimization in the generated > bytecode (see below). Oops, I forgot to include the "see below" bit. Comparing a = a.spam() a .= spam() the Python compiler could perhaps optimize the second

Re: Proposal for new minor syntax

2015-03-28 Thread Steven D'Aprano
On Sat, 28 Mar 2015 07:48 am, Ian Kelly wrote: > On Fri, Mar 27, 2015 at 2:24 PM, Jamie Willis > wrote: >> I would like to propose a new piece of syntax for the python language; .= >> >> In short, the operator is form of syntactic sugar, for instance consider >> the following code: >> >> hello =

Re: Proposal for new minor syntax

2015-03-28 Thread Steven D'Aprano
On Sat, 28 Mar 2015 10:08 am, BartC wrote: > An alternate syntax might be: > > hello = .string() > loop_node =. next Why propose that? Every other augmented assignment has the operator on the left hand side of the equals. Greater-than, less-than, and not-equal all have the symbol on the lef

Re: VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-27 Thread Chris Angelico
On Sat, Mar 28, 2015 at 5:26 PM, Steven D'Aprano wrote: > On Sat, 28 Mar 2015 03:18 pm, Rustom Mody wrote: > >> One thing that is a bit laborious in python are object initializers: >> >> self.attr1 = field1 >> self.attr2 = field2 >> >> In VB one can do: >> >> with self >> .attr1 = field1 >> .attr2

VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-27 Thread Steven D'Aprano
On Sat, 28 Mar 2015 03:18 pm, Rustom Mody wrote: > One thing that is a bit laborious in python are object initializers: > > self.attr1 = field1 > self.attr2 = field2 > > In VB one can do: > > with self > .attr1 = field1 > .attr2 = field2 > > (or something like that -- dont exactly remember the

Re: Proposal for new minor syntax

2015-03-27 Thread Rustom Mody
On Saturday, March 28, 2015 at 6:26:26 AM UTC+5:30, Ian wrote: > On Fri, Mar 27, 2015 at 6:33 PM, Mario Figueiredo wrote: > > On Sat, 28 Mar 2015 10:39:04 +1100, Ben Finney wrote: > > > >>Jamie Willis writes: > >> > >>> This could be written as: > >>> > >>> hello = "hello world " > >>

Re: Proposal for new minor syntax

2015-03-27 Thread Ian Kelly
On Fri, Mar 27, 2015 at 6:33 PM, Mario Figueiredo wrote: > On Sat, 28 Mar 2015 10:39:04 +1100, Ben Finney > wrote: > >>Jamie Willis writes: >> >>> This could be written as: >>> >>> hello = "hello world " >>> hello .= strip() >> >>?1, “.=” is visually too similar to “=”. > > can't be

Re: Proposal for new minor syntax

2015-03-27 Thread Mario Figueiredo
On Sat, 28 Mar 2015 10:39:04 +1100, Ben Finney wrote: >Jamie Willis writes: > >> This could be written as: >> >> hello = "hello world " >> hello .= strip() > >?1, “.=” is visually too similar to “=”. can't be much worse than hello = "hello world", I think the dot next to

Re: Proposal for new minor syntax

2015-03-27 Thread Ben Finney
Jamie Willis writes: > This could be written as: > > hello = "hello world " > hello .= strip() −1, “.=” is visually too similar to “=”. Syntax that is ambiguous at a glance is a cost when reading, and here I think the cost is great. > In this slightly contrived example, the progra

Re: Proposal for new minor syntax

2015-03-27 Thread BartC
On 27/03/2015 20:48, Ian Kelly wrote: On Fri, Mar 27, 2015 at 2:24 PM, Jamie Willis wrote: I would like to propose a new piece of syntax for the python language; .= In short, the operator is form of syntactic sugar, for instance consider the following code: hello = "hello world "

Re: Proposal for new minor syntax

2015-03-27 Thread Skip Montanaro
Interesting concept. I suppose it offers some small optimization opportunities, and clearly saves some possibly error-prone typing. You construct the object on the left-hand side, then just DUP_TOP to get its use on the RHS. A couple comments though: * "dot" is pretty invisible unless surrounded

Re: Proposal for new minor syntax

2015-03-27 Thread Ian Kelly
On Fri, Mar 27, 2015 at 2:24 PM, Jamie Willis wrote: > I would like to propose a new piece of syntax for the python language; .= > > In short, the operator is form of syntactic sugar, for instance consider the > following code: > > hello = "hello world " > hello = hello.strip() > > Th

Proposal for new minor syntax

2015-03-27 Thread Jamie Willis
I would like to propose a new piece of syntax for the python language; .= In short, the operator is form of syntactic sugar, for instance consider the following code: hello = "hello world " hello = hello.strip() This could be written as: hello = "hello world " hello .=