On Thu, Sep 15, 2011 at 9:37 AM, opinali <[email protected]> wrote:
> I read the C# example, and it didn't impress me; it's not just contrived,
> it's a VERY contrived example. You can easily build such examples to show
> that every single feature of any language can be involved in some
> incorrect/confusing code. In the example, the bug is not caused only by
> mutable capture - it's mostly likely caused by programmer's failure to
> realize that the execution of the closure will be deferred. This is the most
> fundamental property of a closure if compared to a regular block or
> expression inside the containing method; developers can shoot themselves in
> the foot all day long if they fail to be aware of when the code of closures
> is actually executed, without even needing mutable capture. Taking a page
> from lambda-dev (from Neal Gafter IIRC), closures (including mutable
> capture) are an ages-old feature which use is time-proven by numerous
> languages.

Just lifting the variable to a field means you have completely moved
the memory semantics of it.  Suddenly "volatile" is a relevant
modifier of a local variable.  Well, some of them. :)  (Right?)

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to