Blocks for scope control



See
http://stackoverflow.com/questions/1563030/anonymous-code-blocks-in-java
for a general discussion.

I'm talking specifically about the block by itself: a pair of braces by
themselves, enclosing some code in a method. On occasion I do run across
situations where a judicious use of such a block inside a method, to
restrict variable visibility, is handy.

I almost never see anyone else using these things this way. A block in a
method always seems to be associated with a control construct or
exception handling. As any number of references point out, you wouldn't
expect to see many usages of local blocks, mainly because 99 times out
of 100 that situation is probably handled best by a new method. But in
my years of looking at Java it occurs to me that I barely see any use of
this at all...even where it wouldn't be a bad idea.

Any thoughts?

AHS
--
....wherever the people are well informed they can be trusted with their
own government...
-- Thomas Jefferson, 1789
.



Relevant Pages

  • Re: ieeetran bibtex style mangles author names
    ... was in the habit of placing quotation marks _outside of_ the enclosing ... title = "{Kung Foo in Thirty Seconds}" ... handling of quotes and braces as outer delimiters is identical. ...
    (comp.text.tex)
  • Re: ieeetran bibtex style mangles author names
    ... by an extra set of braces. ... As for controlling the capitalization of document titles in BibTeX, ... was in the habit of placing quotation marks _outside of_ the enclosing ...
    (comp.text.tex)
  • Re: ieeetran bibtex style mangles author names
    ... by an extra set of braces. ... As for controlling the capitalization of document titles in BibTeX, ... was in the habit of placing quotation marks _outside of_ the enclosing ...
    (comp.text.tex)
  • Re: ieeetran bibtex style mangles author names
    ... by an extra set of braces. ... As for controlling the capitalization of document titles in BibTeX, ... was in the habit of placing quotation marks _outside of_ the enclosing ...
    (comp.text.tex)
  • Re: ieeetran bibtex style mangles author names
    ... by an extra set of braces. ... As for controlling the capitalization of document titles in BibTeX, ... was in the habit of placing quotation marks _outside of_ the enclosing ...
    (comp.text.tex)