Re: Anonymous class - I don't know how to...



Twisted <twisted0n3@xxxxxxxxx> wrote:
You can work around it too, by using final arrays or final objects
with mutable fields. In fact, you can get closure-like behavior:

It's good that you mentioned the use of arrays for sharing
non-final data with a closure. I plainly forgot to mention this
workaround, myself.

However, I didn't understand the necessity of involving exceptions.
whenever the closure has done its job, you just access the array
element in the outer object, no matter if any exceptions were
thrown from the closure or whether it returned normally.

Even more, if you pass the closure to somewhere, where it is
supposed to be "used" more than once, then your exception-throwing
closure will break that after its first use.

Surely there are cases, where you want to throw exceptions
from the closure, but that isn't at all related to sharing data.

.



Relevant Pages

  • Re: What will be the next MAJOR programming language for commercial use?
    ... >> This is a very low-level notion of a closure that I've never come across. ... > I've made just this argument in support of D's builtin arrays, ... important, primitive language constructs. ... addition to D (provided you also support pattern matching). ...
    (comp.lang.misc)
  • Re: SICP footnote on closures
    ... The word "closure" in this paragraph does not mean "the thing LAMBDA ... but not an array of arrays of integers. ... you can't write a procedure like MAP that works on sequences ...
    (comp.lang.scheme)
  • Re: ruby one-liner needed
    ... I have 2 arrays and I'd like to change them into a Hash ... (I wanted to eliminate the '; hash' at the end of the closure but couldn't ... Ross Bamford - rosco@xxxxxxxxxxxxxxxxxxxxxx ...
    (comp.lang.ruby)