Re: New syntax for blocks

2009-11-20 Thread Gregory Ewing
Steven D'Aprano wrote: I don't know what the state of the art on Mac is these days, but in 1984s Macs had a standard keyboard layout that let you enter most available characters via the keyboard, using sensible mnemonics. E.g. on a US keyboard layout, you could get ≠ by holding down the

Re: New syntax for blocks

2009-11-20 Thread Carl Banks
On Nov 19, 12:20 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Steven D'Aprano wrote: I don't know what the state of the art on Mac is these days, but in 1984s Macs had a standard keyboard layout that let you enter most available characters via the keyboard, using sensible

Re: New syntax for blocks

2009-11-20 Thread Ben Finney
Carl Banks pavlovevide...@gmail.com writes: On Nov 19, 12:20 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: They all still seem to work -- presumably generating the appropriate unicode characters now instead of MacRoman. ³It¹s about time.² I � Unicode. (lrf, gung *vf* qryvorengr,

Re: New syntax for blocks

2009-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2009 18:28:11 +1300, greg wrote: r wrote: I think the syntax was chosen because the alternatives are even worse AND since assignment is SO common in programming, would you *really* rather type two chars instead of one? Smalltalk solved the problem by using a left-arrow

Re: New syntax for blocks

2009-11-18 Thread r
On Nov 18, 5:27 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Wed, 18 Nov 2009 18:28:11 +1300, greg wrote: r wrote: I think the syntax was chosen because the alternatives are even worse AND since assignment is SO common in programming, would you *really* rather type

RE: New syntax for blocks

2009-11-17 Thread Jonathan Saxton
On Thu, 12 Nov 2009 21:27:31 +0100, Bruno Desthuilliers wrote: Congratulations, you just reinvented one of the most infamous source of bugs in C, C++, Java, PHP, javascript and quite a few other languages. Believe it or not, but not allowing this in Python was a very deliberate design choice.

Re: New syntax for blocks

2009-11-17 Thread MRAB
Jonathan Saxton wrote: On Thu, 12 Nov 2009 21:27:31 +0100, Bruno Desthuilliers wrote: Congratulations, you just reinvented one of the most infamous source of bugs in C, C++, Java, PHP, javascript and quite a few other languages. Believe it or not, but not allowing this in Python was a very

Re: New syntax for blocks

2009-11-17 Thread r
On Nov 17, 9:28 am, Jonathan Saxton jsax...@appsecinc.com wrote: And if I ever find the genius who had the brilliant idea of using = to mean assignment then I have a particularly nasty dungeon reserved just for him.   Also a foul-smelling leech-infested swamp for those language designers and

Re: New syntax for blocks

2009-11-17 Thread Nobody
On Tue, 17 Nov 2009 17:31:18 +, MRAB wrote: And if I ever find the genius who had the brilliant idea of using = to mean assignment then I have a particularly nasty dungeon reserved just for him. Also a foul-smelling leech-infested swamp for those language designers and compiler writers

Re: New syntax for blocks

2009-11-17 Thread Russ P.
On Nov 17, 7:28 am, Jonathan Saxton jsax...@appsecinc.com wrote: On Thu, 12 Nov 2009 21:27:31 +0100, Bruno Desthuilliers wrote: Congratulations, you just reinvented one of the most infamous source of bugs in C, C++, Java, PHP, javascript and quite a few other languages. Believe it or not,

Re: New syntax for blocks

2009-11-17 Thread greg
MRAB wrote: Fortran uses = and .EQ., probably because (some) earlier autocodes did. I think Fortran used .LT. and .GT. because some early character sets didn't have and symbols. Having done that, it probably seemed more consistent to use .EQ. for comparison than to break the pattern and use

Re: New syntax for blocks

2009-11-17 Thread greg
r wrote: I think the syntax was chosen because the alternatives are even worse AND since assignment is SO common in programming, would you *really* rather type two chars instead of one? Smalltalk solved the problem by using a left-arrow character for assignment. But they had an unfair

Re: New syntax for blocks

2009-11-13 Thread Bruno Desthuilliers
r a écrit : On Nov 12, 7:44 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote Oh, but those hundreds of thousands of man-hours lost to bugs caused by assignment-as-an-expression is nothing compared to the dozens of man- minutes saved by having one fewer line of code! OK, what

Re: New syntax for blocks

2009-11-13 Thread Bruno Desthuilliers
r a écrit : On Nov 12, 2:37 pm, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Oh i get it now! If i assign a valid value to a variable the variable is also valid...thats...thats... GENUIS! *sarcasm* It's not about assigning a valid value to a variable, it's about the

Re: New syntax for blocks

2009-11-13 Thread r
On Nov 13, 3:20 pm, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: (...snip...) I think because (like me) Carl put's the language before sewing circles. I think it's just personal like all the times before, Well, to be true, you did manage to make a clown of yourself

Re: New syntax for blocks

2009-11-12 Thread Steven D'Aprano
On Wed, 11 Nov 2009 03:52:45 -0800, Carl Banks wrote: This is where a helper function is good. You want a dispatcher: No I really don't. I want to be able to see the action performed adjacent to the test, and not have to scroll up to down ten pages to find whatever function it dispatched

Re: New syntax for blocks

2009-11-12 Thread Bruno Desthuilliers
r a écrit : -snip) Just thinking out loud here...what if variable assignments could return a value... hmmm? Not to them selfs of course but to a caller, like an if statement... if a=openfile: # do something with a Congratulations, you just reinvented one of the most infamous source of

Re: New syntax for blocks

2009-11-12 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : (snip) Hint to would-be language designers: if you start off by claiming that a new feature will save an indent level, when in fact it *doesn't* save an indent level, you can save yourself from embarrassment by pressing Close on your post instead of Send.

Re: New syntax for blocks

2009-11-12 Thread Bruno Desthuilliers
r a écrit : On Nov 11, 2:37 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Wed, 11 Nov 2009 00:08:58 -0800, r wrote: Yea it's called a NameError. Would it not also blow up in the current state of syntax usage? No. if var: print 'var' Traceback (most recent call

Re: New syntax for blocks

2009-11-12 Thread r
On Nov 12, 2:37 pm, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Oh i get it now! If i assign a valid value to a variable the variable is also valid...thats...thats... GENUIS! *sarcasm* It's not about assigning a valid value to a variable, it's about the name being

Re: New syntax for blocks

2009-11-12 Thread Steven D'Aprano
On Thu, 12 Nov 2009 21:27:31 +0100, Bruno Desthuilliers wrote: Congratulations, you just reinvented one of the most infamous source of bugs in C, C++, Java, PHP, javascript and quite a few other languages. Believe it or not, but not allowing this in Python was a very deliberate design choice.

Re: New syntax for blocks

2009-11-12 Thread r
On Nov 12, 7:44 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote Oh, but those hundreds of thousands of man-hours lost to bugs caused by assignment-as-an-expression is nothing compared to the dozens of man- minutes saved by having one fewer line of code! OK, what *if* the

Re: New syntax for blocks

2009-11-12 Thread Stephen Hansen
On Thu, Nov 12, 2009 at 8:10 PM, r rt8...@gmail.com wrote: On Nov 12, 7:44 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote Oh, but those hundreds of thousands of man-hours lost to bugs caused by assignment-as-an-expression is nothing compared to the dozens of man- minutes

Re: New syntax for blocks

2009-11-11 Thread r
On Nov 11, 1:25 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: (snip) Incorrect. True == None False False == None False Of course i meant True/False but my fingers were thinking None at the time. And besides if i don't make a mistake here or there what ever would you do

Re: New syntax for blocks

2009-11-11 Thread Steven D'Aprano
On Wed, 11 Nov 2009 00:08:58 -0800, r wrote:    #variable var will never be created! That will cause no end of trouble. if range(N) as var:     do_something_with_var() if var:     print Oops, this blows up if N = 0 Conditional assignments are a terrible idea. Yea it's called a

Re: New syntax for blocks

2009-11-11 Thread r
On Nov 11, 2:37 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Wed, 11 Nov 2009 00:08:58 -0800, r wrote: Yea it's called a NameError. Would it not also blow up in the current state of syntax usage? No. if var:     print 'var' Traceback (most recent call last):

Re: New syntax for blocks

2009-11-11 Thread Carl Banks
On Nov 10, 9:37 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 10 Nov 2009 20:13:21 -0800, Carl Banks wrote: On Nov 10, 7:12 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 10 Nov 2009 12:45:13 -0800, Bearophile wrote: r: i think the

Re: New syntax for blocks

2009-11-11 Thread Carl Banks
On Nov 10, 9:44 pm, Terry Reedy tjre...@udel.edu wrote: Carl Banks wrote: r didn't actually give a good example.  Here is case where it's actually useful.  (Pretend the regexps are too complicated to be parsed with string method.) if re.match(r'go\s+(north|south|east|west)',cmd) as m:

Re: New syntax for blocks

2009-11-11 Thread steve
Hi, On 11/11/2009 12:30 PM, r wrote: [...snip...] I think what has escaped everyone (including myself until my second post) is the fact that what really needs to happen is for variable *assignments* to return a boolean to any statements that evaluate the assignment -- like in an if or elif

Re: New syntax for blocks

2009-11-11 Thread samwyse
On Nov 10, 1:23 pm, r rt8...@gmail.com wrote: Forgive me if i don't properly explain the problem but i think the following syntax would be quite beneficial to replace some redundant if's in python code. if something_that_returns_value() as value:     #do something with value # Which can

Re: New syntax for blocks

2009-11-11 Thread Robert Latest
r wrote: Just thinking out loud here...what if variable assignments could return a value... hmmm? Not to them selfs of course but to a caller, like an if statement... if a=openfile: # do something with a That's like in C. I sometimes miss it in Python. robert --

Re: New syntax for blocks

2009-11-11 Thread Terry Reedy
Steven D'Aprano wrote: Why is the third example, with an if... test, so special that it needs special syntax to make it a two-liner? ...because Beautiful is better than ugly. I can quote the Zen too: Special cases aren't special enough to break the rules. You haven't demonstrated that your

Re: New syntax for blocks

2009-11-11 Thread Steven D'Aprano
On Wed, 11 Nov 2009 04:00:09 -0800, Carl Banks wrote: as has been posted before and again in a slightly different form in Steve's post. I'm well aware of it, but I didn't think the proposal deserved to be called stupid when it was a reasonable solution to a real need, even though a

Re: New syntax for blocks

2009-11-11 Thread Carl Banks
On Nov 11, 4:12 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Wed, 11 Nov 2009 03:52:45 -0800, Carl Banks wrote: This is where a helper function is good. You want a dispatcher: No I really don't.  I want to be able to see the action performed adjacent to the test, and

Re: New syntax for blocks

2009-11-11 Thread r
On Nov 11, 9:04 pm, Carl Banks pavlovevide...@gmail.com wrote: (Carl's reply to Steven's comments...) Well I don't just want to call a method, so I can't take that advice. Some actions will do more than just to call a method. And I don't want to scroll up or down ten screens to see what the

Re: New syntax for blocks

2009-11-10 Thread Robert Latest
r wrote: Forgive me if i don't properly explain the problem but i think the following syntax would be quite beneficial to replace some redundant if's in python code. if something_that_returns_value() as value: #do something with value # Which can replace the following syntactical

Re: New syntax for blocks

2009-11-10 Thread steve
Hi, On 11/11/2009 12:53 AM, r wrote: Forgive me if i don't properly explain the problem but i think the following syntax would be quite beneficial to replace some redundant if's in python code. if something_that_returns_value() as value: #do something with value # Which can replace the

Re: New syntax for blocks

2009-11-10 Thread steve
On 11/11/2009 02:05 AM, steve wrote: Hi, On 11/11/2009 12:53 AM, r wrote: [...snip...] i dunno, just seems to make good sense. You save one line of code but more importantly one indention level. However i have no idea how much trouble the implementation would be? I guess the problem would

Re: New syntax for blocks

2009-11-10 Thread Bearophile
r: i think the following syntax would be quite beneficial to replace some redundant if's in python code. http://python.org/dev/peps/pep-3003/ bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: New syntax for blocks

2009-11-10 Thread r
On Nov 10, 2:08 pm, Robert Latest boblat...@yahoo.com wrote: (..snip..) Also it's not the if that is (if at all) redundant here but the assignment. Not exactly. The assignment happens only once just as the boolean check of if value happens once. The redundancy is in validating the existence of a

Re: New syntax for blocks

2009-11-10 Thread Steven D'Aprano
On Tue, 10 Nov 2009 12:45:13 -0800, Bearophile wrote: r: i think the following syntax would be quite beneficial to replace some redundant if's in python code. http://python.org/dev/peps/pep-3003/ I knew it wouldn't take long for people to start responding to any proposal with don't

Re: New syntax for blocks

2009-11-10 Thread Carl Banks
On Nov 10, 11:23 am, r rt8...@gmail.com wrote: if something_that_returns_value() as value:     #do something with value Been proposed before. No one has bothered to write a PEP for it, so I can't say for sure how the Python gods would react, but I suspect a meh, don't think it's important

Re: New syntax for blocks

2009-11-10 Thread Carl Banks
On Nov 10, 7:12 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 10 Nov 2009 12:45:13 -0800, Bearophile wrote: r: i think the following syntax would be quite beneficial to replace some redundant if's in python code. http://python.org/dev/peps/pep-3003/ I knew it

Re: New syntax for blocks

2009-11-10 Thread r
On Nov 10, 9:12 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: (..snip..) Hint to would-be language designers: if you start off by claiming that a new feature will save an indent level, when in fact it *doesn't* save an indent level, you can save yourself from embarrassment by

Re: New syntax for blocks

2009-11-10 Thread Steven D'Aprano
On Tue, 10 Nov 2009 20:13:21 -0800, Carl Banks wrote: On Nov 10, 7:12 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 10 Nov 2009 12:45:13 -0800, Bearophile wrote: r: i think the following syntax would be quite beneficial to replace some redundant if's in python

Re: New syntax for blocks

2009-11-10 Thread Terry Reedy
Carl Banks wrote: r didn't actually give a good example. Here is case where it's actually useful. (Pretend the regexps are too complicated to be parsed with string method.) if re.match(r'go\s+(north|south|east|west)',cmd) as m: hero.move(m.group(1)) elif re.match(r'take\s+(\w+)',cmd) as

Re: New syntax for blocks

2009-11-10 Thread r
On Nov 10, 2:49 pm, steve st...@lonetwin.net wrote: (..snip..) However, the same 'effect' can be obtained with the 'with' statement: (..snip..) Hardly!,Here is an interactive session with your test case #--# class

Re: New syntax for blocks

2009-11-10 Thread Steven D'Aprano
On Tue, 10 Nov 2009 23:00:09 -0800, r wrote: I think what has escaped everyone (including myself until my second post) is the fact that what really needs to happen Why? is for variable *assignments* to return a boolean to any statements that evaluate the assignment -- like in an if or