Arbitrary abbreviations in phobos considered ridiculous

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Mar 7 11:14:05 PST 2012


On Wed, Mar 07, 2012 at 01:50:03PM -0500, Nick Sabalausky wrote:
> "Jacob Carlborg" <doob at me.com> wrote in message 
> news:jj74p4$n9r$3 at digitalmars.com...
> > On 2012-03-07 03:18, Nick Sabalausky wrote:
[...]
> >> I say fuck it: Let's just toss this into core.time (or std.datetime
> >> or whatever) and be done:
> >>
> >> alias dur!"years" years;
> >> alias dur!"months" months;
> >> alias dur!"weeks" weeks;
> >> alias dur!"days" days;
> >> alias dur!"hours" hours;
> >> alias dur!"minutes" minutes;
> >> alias dur!"seconds" seconds;
> >> alias dur!"msecs" msecs;
> >> alias dur!"usecs" usecs;
> >> alias dur!"hnsecs" hnsecs;
> >>
> >> And then we have the brevity issue solved (and in fact, improved
> >> over "dur"), so then "dur" can (and should) change to "duration"
> >> without screwing up brevity. And all probelms are optimally solved.
> >> As for the possibility of new name collisions: Honestly, in this
> >> case I see no reason to give a shit.
> >
> > I agree, adding these aliases would be a good idea.
> >
> 
> I like that so many people agree with this. But I do want to point out
> again, just in case anyone missed it, that I'm hoping it would
> *actually* be:
> 
> alias duration!"years" years;
> alias duration!"months" months;
> etc...
> 
> Since the aliases themselves mitigate the need for "duration" itself to be 
> shortened.

+1.


> Course, I can still live with just 'alias dur!"years" years;..etc...'.
> The *main* thing is that we can just do "hours(5)"...(or heck, once
> UFCS finally gets fixed: "5.hours")
[...]

Hooray! Ruby syntax FTW!

Tangential comment:

Before I discovered D, Ruby was among the top candidates in my list of
programming languages close to my ideals. Once D pulls off UFCS, it will
trump Ruby in so many more ways... such as being able to effectively
extend class methods just by declaring module-level functions of the
form:

	retType func(classname obj, ...);

(which I believe is already (somewhat?) supported). Among many other
things.

Supporting stuff like 5.hours will introduce additional complications to
D's lexical structure, though. The lexer will have to understand it as
(int:5)(.)(ident:hours) rather than (float:5.)(ident:hours). And then if
you actually *wanted* a float, you'd have another ambiguity: 5..hours
could mean (float:5.)(.)(ident:hours) or (int:5)(..)(hours). And
5.0.hours just looks... weird.


T

-- 
"How are you doing?" "Doing what?"


More information about the Digitalmars-d mailing list