Arbitrary abbreviations in phobos considered ridiculous

Nick Sabalausky a at a.a
Wed Mar 7 14:00:18 PST 2012


"H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message 
news:mailman.175.1331147548.4860.digitalmars-d at puremagic.com...
> On Wed, Mar 07, 2012 at 01:50:03PM -0500, Nick Sabalausky wrote:
>> 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.
>

I'm not really much of a ruby fan, except in comparison to python (I think 
ruby's whole "It's like English, just write it like you'd expect it to be 
written" thing is both untrue and misguided). But yea, UFCS is awesome 
(erm..."will be" awesome...eventually...I hope...).

> 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.
>

That "5."/".5" float syntax need to die anyway. It's just pointless and gets 
in the way of things that *aren't* pointless like UFCS.

I agree that "5.0.hours" looks a little weird, but meh, it's good enough and 
there's no fundamental problem with it (and it's a hell of a lot better than 
"5. .hours"). And you can just do "(5.0).hours" if you really want.




More information about the Digitalmars-d mailing list