Variable's DA status not changing within body of closure

Mark Mahieu mark at twistedbanana.demon.co.uk
Sun May 18 15:03:57 PDT 2008


Hmm, I realize that the closure can't have any impact on the  
variable's DA/DU status outside of the closure body, regardless of  
how it is (or isn't executed), but I still don't see why the variable  
i 'might not have been initialized' at the point I'm incrementing it  
within the body of the closure, since the preceding statement - also  
within the closure body - assigns to it.

Puzzled,

Mark


On 18 May 2008, at 21:52, Neal Gafter wrote:

> This is correct.  The fact that the exec method definitely executes  
> the closure it receives is not part of its type.
>
> On Sun, May 18, 2008 at 7:17 AM, Mark Mahieu  
> <mark at twistedbanana.demon.co.uk> wrote:
> This doesn't look quite right:
>
>
> public class DefinitelyAssigned {
>
>    public static void main(String[] args) {
>
>        int i;
>
>        exec() {
>            i = 0;
>            i++;
>        }
>    }
>
>    static void exec({==>void} block) {
>        block.invoke();
>    }
> }
>
>
> DefinitelyAssigned.java:9: variable i might not have been initialized
>                        i++;
>                        ^
> 1 error
>
>
>
> Regards,
>
> Mark
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080518/b8955747/attachment.html 


More information about the closures-dev mailing list