ARM Blocks: ease of use and for loops
Howard Lovatt
howard.lovatt at iee.org
Wed Nov 11 12:33:16 PST 2009
This issue of passing the iterable (not iterator, in the case of my code)
through many methods is why I suggest a SafeCloseable that doesn't throw
exceptions. It is practical to pass SafeCloseable through many methods
without them all becoming 'infected' with throws exception. Would this
solution work with Google Collections?
2009/11/11 Kevin Bourrillion <kevinb at google.com>
> I realized that this is not as useful as I was hoping it would be.
>
> Many users at Google are not iterating through the source data directly,
> but are passing that iterator through methods like transform() and filter()
> and many others (
> http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Iterators.html
> ).
>
> I can't stand the thought of having to descend into RandomAccess-style
> hell, so passing an iterator through these methods will likely wipe the
> Closeable right off, making the foreach improvement less applicable.
>
> I withdraw my +10, which is not to say that I am arguing against it.
>
>
>
> On Sun, Nov 8, 2009 at 8:09 AM, Kevin Bourrillion <kevinb at google.com>wrote:
>
>> Thread-resurrect...
>>
>> I think detecting 'iterator instanceof Closeable' is an outstanding
>> idea, and one that would solve problems that have been vexing me as a
>> library developer for years.
>>
>> The foreach construct owns the creation of that instance, and is the
>> only party that has a reference to it. If the instance is Closeable,
>> it feels simply irresponsible to ignore this.
>>
>> As for the potential risks, we're talking about an instance that's
>> unreachable and eligible for GC, so it's difficult to imagine that
>> closing such an instance could be a bad idea. Looked another way, if
>> a user didn't want automatic close for some reason, that reason would
>> already be preventing that user from using foreach anyway.
>>
>> +10
>>
>>
>>
>> On Thu, Oct 22, 2009 at 8:19 AM, Neal Gafter <neal at gafter.com> wrote:
>> > On Thu, Oct 22, 2009 at 8:59 AM, Howard Lovatt <howard.lovatt at iee.org
>> >wrote:
>> >
>> >> I think you can choose if close to applies to the Iterable or the
>> Iterator.
>> >
>> >
>> > Agreed. But if it applies to the Iterable, the programmer can easily use
>> an
>> > ARM block around the for-each loop. If it applies to the Iterator,
>> there is
>> > no way for the programmer to do it. That's why support is needed in
>> that
>> > case.
>> >
>> >
>>
>>
>>
>> --
>> Kevin Bourrillion @ Google
>> internal: http://go/javalibraries
>> external: guava-libraries.googlecode.com
>>
>
>
>
> --
> Kevin Bourrillion @ Google
> internal: http://go/javalibraries
> external: guava-libraries.googlecode.com
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
--
-- Howard.
More information about the coin-dev
mailing list