@Shared warning

Zdenek Tronicek tronicek at fel.cvut.cz
Mon May 19 01:43:55 PDT 2008


If we declare a closure with read-only access to a local variable,  
there is no warning:

   int n = 10;
   { => int } f = { => n };

If a closure modifies the variable captured

   { => int } f = { => n--; n == 0 ? 1 : f.invoke() };

there is a warning (which is right). But why is the warning also on  
place where the variable is read only?

Recursion.java:17: warning: [shared] captured variable n not annotated @Shared
         { => int } f = { => n--; n == 0 ? 1 : f.invoke() };
                             ^
Recursion.java:17: warning: [shared] captured variable n not annotated @Shared
         { => int } f = { => n--; n == 0 ? 1 : f.invoke() };
                                  ^
2 warnings

Z.
-- 
Zdenek Tronicek
Department of Computer Science and Engineering
Prague                   tel: +420 2 2435 7410
http://cs.felk.cvut.cz/~tronicek









More information about the closures-dev mailing list