|
Re: Sky pie: a "var" keyword: msg#00044python.python-3000.devel
Neil Toronto <ntoronto@xxxxxxxxxx> writes: > For the record, though I didn't present it this way in my initial > proposal, I like #1 and #2 better than #3. Otherwise, you'd get this > silliness: > > def f(): > x = 3 # fine, because the magic 'var' down below creates it > var x = 0 In my semantics #3 this would be a runtime error at the assignment (the compiler could catch it statically in this case, but not always). Neil Toronto <ntoronto@xxxxxxxxxx> writes: > var x = 0 > def f(): > if sometest: > var x = 3 > > x = 2 > > which is seriously evil, because it's not clear which 'x' the last > assignment refers to. Should be: var x = 0 def f(): var x if sometest: x = 3 x = 2 For 'for' loops there are two choices: 1. 'for x in coll' creates x which is local to the loop. 2. 'for var x in coll' creates a local x, 'for x in coll' modifies an existing x. I admit that Python choices of expressing certain constructs (conditionals, loops) as statements instead of expressions make a sane semantics of variable declarations less convenient. -- __("< Marcin Kowalczyk \__/ qrczak@xxxxxxxxxx ^^ http://qrnik.knm.org.pl/~qrczak/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: ugly pie: a "var" keyword: 00044, Antoine Pitrou |
|---|---|
| Next by Date: | Re: ugly pie: a "var" keyword: 00044, Georg Brandl |
| Previous by Thread: | Re: Sky pie: a "var" keywordi: 00044, Neil Toronto |
| Next by Thread: | Re: Kill GIL? - to PEP 3099?: 00044, Ivan Krstić |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |