try/catch idiom in std.datetime
Jonathan M Davis
jmdavisProg at gmx.com
Tue Nov 19 02:32:39 PST 2013
On Tuesday, November 19, 2013 08:30:56 Jacob Carlborg wrote:
> On 2013-11-18 23:33, Andrei Alexandrescu wrote:
> > So that would be two empty lines between statements :o). Anyhow,
> > assuming you only meant one, that would be excessive if done for _all_
> > statements (i.e. everything ending with a semicolon). It would make code
> > look like a doc printed by someone who didn't know how to turn double
> > spacing off.
>
> I don't agree. And not having any empty newlines in the code would be
> like reading a text without paragraphs, as I've already said.
>
> Instead, take a look at some code I've written and you're free to
> thinking whatever you like, but I like that style.
>
> https://github.com/jacob-carlborg/dstep/blob/master/dstep/translator/Transla
> tor.d
That looks pretty good overall, though there are probably a few places where
I'd favor having fewer newlines. e.g. the body of the foreach in
translateFunction is formatted similarly to what I'd do by default, but the
overall feel is that it has too much vertical space. So, I might be inclined
to remove some of the newlines, much as I'd want them by default. The fact
that you have braces on the first version block doesn't help either. But the
formatting is okay.
While I suspect that Andrei would definitely want to remove many of those
newlines if he were formatting the code, what I think Andrei was really
objecting to in your comments said that you wanted to put a newline after
_every_ statement (which you're not actually doing in your code), and then you
wanted separate lines between "paragraphs of code," implying that you'd end up
with two newlines separating out sections of your functions. And that would be
a lot of extraneous newlines. What you actually seem to have is putting a
newline around "paragraphs" but not a newline between every statement, which
is a lot more reasonable (though if your "paragraphs" are too small, you run
into the exact problem that Andrei was commenting on in my code that started
this discussion).
By the way, you have a lot of useless breaks in your code. A break isn't
actually required if there's a return statement or other control statement
such as continue at the end of the case statement. Maybe it's a stylistic
thing? But in case you didn't know, they're completely unnecessary, and
personally, I'd consider them to be clutter. It's your code though, not mine.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list