Arbitrary abbreviations in phobos considered ridiculous

Jonathan M Davis jmdavisProg at gmx.com
Tue Mar 6 16:25:00 PST 2012


On Tuesday, March 06, 2012 20:58:52 Ary Manzana wrote:
> On 3/6/12 8:43 PM, Jonathan M Davis wrote:
> > On Tuesday, March 06, 2012 17:38:09 Adam D. Ruppe wrote:
> >> writeln(time.toISOExtendedString()); // bzzt, wrong, but this
> >> used to work!
> > 
> > Yes, and it was quickly changed to toISOExtString, because
> > toISOExtendedString is painfully long. toISOExtString is bad enough, but
> > you can't really make it any shorter without making the name
> > uninformative.
> > 
> >> Nope, apparently, I meant "dur". Ridiculous.
> > 
> > A Duration needs to be constructed with a template, and
> > duration!"hours"(13), duration!"seconds"(44), etc. is painfully long when
> > used in expressions. So, it was shortened to dur. I don't know of any
> > other abbreviation which would make sense.
> 
> Painfully long?
> 
> How much time does it take you to type 5 more chars? How much time does
> it take you to understand "dur" when you read it instead of "duration"?
> 
> > I agree with H.S. Teoh in that abbreviations should be meaniful and
> > consistent but that they _should_ be used where applicable. Code becomes
> > painfully long otherwise - especially when chaining function calls and
> > the like.
> 
> Code becomes painfully long when you write lots of lines, not when you
> write long lines. Specially when you write lots of boilerplate lines.

You don't write much code in functional style, do you? If you chain functions 
much, then long names very quickly result in long lines, which makes the code 
harder to read, and can quickly lead to expressions having to be multiple 
lines, simply because the symbol names involved were overly verbose.

While, I grant you that duration!"minutes"(5) might be more immediately clear 
than dur!"minutes"(5) is, I don't buy that it makes all that much of a 
differences. You're not going to mistake dur for anything else even if it 
doesn't immediately occur to you that it's an abbreviation for duration, and 
the units make it very clear that it's related to time. And since dur is 
something that's likely to be commonly used, it will very quick and easy to 
remember what it is.

No, dur is not a fantastic name, but when I had to choose between a name which 
become very long when combined with the required template argument, and dur, 
which is perfectly clear with minimal explanation - albeit not as clear as 
duration would be - but makes the symbol name shorter and therefore less of an 
issue to use in longer expressions, I went with the shorter name.

If anything, I'd argue that std.datetime and core.time have too many symbol 
names which are overly long in their attempt to be appropriately descriptive. 
I would have expected people to be complaining about the verboseness of some 
of them, not that some of them were abbreviated.

- Jonathan M Davis


More information about the Digitalmars-d mailing list