Re: Ugly inconsistence betw. for and for/in
Jochen Theodorou <[email protected]>
| Newsgroups | gmane.comp.lang.groovy.devel |
|---|---|
| Message-ID | <[email protected]> |
On 05.09.25 18:10, OCsite wrote: [...] > === > def foo // [1] > ... > for (def foo in ....) // would not use [1], would scope a new variable > instead > for (foo in ...) // would use [1] > === > > If you are cosy with breaking backward compatibility, well, you should > do /this/ change, not /that/ one which breaks it for no benefit at all. the first for-loop must not compile because it would invalidate how local variable scoping works in general: we do no allow shadowing of local variables, every local variable name must be unique! But that is besides the point of if the for-loop spawns a new local scope or not. bye Jochen