trying out the prototype (original) (raw)

Joshua Bloch jjb at google.com
Wed Aug 25 11:08:59 PDT 2010


Yep.I have heard this from C# users for seven years or so. I was told by them that we should not repeat this error.

    Josh

On Tue, Aug 24, 2010 at 6:40 AM, Serge Boulay <serge.boulay at gmail.com>wrote:

The "using" block in c# only allows one resource unless the resources are of the same type. To use multiple resources they are nested or stacked

using (StreamWriter w1 = File.CreateText("W1")) using (StreamWriter w2 = File.CreateText("W2")) { // code here } instead of using (StreamWriter w1 = File.CreateText("W1")) { using (StreamWriter w2 = File.CreateText("W2")) { // code here } } Depending on the number of resources, the "using" block nesting can quickly get out of hand.

On 8/24/10, Stephen Colebourne <scolebourne at joda.org> wrote: > > On 24 August 2010 12:14, David Holmes <David.Holmes at oracle.com> wrote: > >> (I guess this forms a case against the try-with-multiple-resources > >> statement in general. The list of semicolon-delimited declarations > >> enclosed by parentheses looks weird, anyway ;-) > > > > I tend to agree the syntax is awkward and far less readable than simply > > nesting the try-with statements. > > Overall, I think the semicolon, multi-resource, aspect is more complex > than the benefits it gives. Clearer code results from nesting the > statements. > > Stephen > >



More information about the coin-dev mailing list