Re: missing out braces
- From: "Mike" <vimakefile@xxxxxxxxx>
- Date: Tue, 21 Feb 2006 11:54:34 -0800
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1e657006cd19d78698ce84@xxxxxxxxxxxxxxxxxxxxxxx
Mike <vimakefile@xxxxxxxxx> wrote:
<snip>
Personally I'd be happy with the braces being compulsary.
To me something being compulsary syntactically is a prime pointer to its
lack of necessity - if it *has* to be there, the compiler should figure
it
out. (I will conveniently omit all cases to the contrary...)
That would be fine if the only thing which read code was the compiler.
However, it's not - there's the reader, too.
There's no *need* for the colon between the name of a class and the
interfaces it implements or its base classes, nor the commas between
those. For instance, you could have:
public class Foo BaseClass ISomeInterface
Similarly there's no need for commas between parameters:
public void Foo (int i long j string x)
I'm jolly glad both of those exist though - the above are both
nightmares to read.
For me, braces add to readability - they mean that things *can't* get
screwed up just because of indentation, and I can use indentation to
make things more readable, breaking up lines and lining things up in
places which look better to *me* rather than to the compiler.
Yes, but you can always indent such that the indentaion does not match the
true nesting. (Although that's harder to do these days.)
The braces thing is a personal issue, but I hope you see my point about
the counter-examples to your general suggestion :)
Sure I do - hence my comment:
I will conveniently omit all cases to the contrary...
I'm not sure about your slippery-slope argument about the colon and commas
above -- I certainly agree that these items shoud be there for readability.
That fact that I use mainly C# and not Python for most of my projects shows
I'm not religious about this issue, but in this case I think Python has the
edge on readability.
Consider:
if ( minute >= 0 && minute < 60 && second >=0 && second < 60)
{
foo(1);
for each ( int e in coll)
{
bar(e);
}
}
vs.
if 0 <= minute < 60 and 0 <= second < 60:
foo(1)
for e in coll:
bar(e)
Python, by not needing braces and statement seperators, not strickly
requiring outer parens, and handling the inequality nicely seems really easy
to read to me (in addition to taking up less room), and there's really no
mistaking what's going on with the indentation.
On the other hand, there's not quite enough sugar around its
object-orientated features, IMHO.
But luckily, the smart editor's have really rendered most of this moot...
m
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: missing out braces
- From: Jon Skeet [C# MVP]
- Re: missing out braces
- References:
- missing out braces
- From: Andrew Bullock
- Re: missing out braces
- From: Mattias Sjögren
- Re: missing out braces
- From: Andrew Bullock
- Re: missing out braces
- From: Nick Hounsome
- Re: missing out braces
- From: Jon Skeet [C# MVP]
- Re: missing out braces
- From: Mike
- Re: missing out braces
- From: Jon Skeet [C# MVP]
- Re: missing out braces
- From: Nick Hounsome
- Re: missing out braces
- From: Mike
- Re: missing out braces
- From: Jon Skeet [C# MVP]
- missing out braces
- Prev by Date: Installing a service through code.
- Next by Date: Re: Posting data using httpwebrequest.
- Previous by thread: Re: missing out braces
- Next by thread: Re: missing out braces
- Index(es):
Relevant Pages
|