Make dur a property?

monarch_dodra monarchdodra at gmail.com
Wed Jan 23 09:03:19 PST 2013


I was using dur, and as powerful as it is, I *hate* typing:

//----
Thread.sleep(dur!"msecs"(100));
//----

Then, this reminded me of an older thread I started:
Neat: UFCS for integer dot operator suffix
http://forum.dlang.org/thread/uchcycnsvykuojzhuokh@forum.dlang.org

And then it struct me:
//----
Thread.sleep(100.dur!"msecs");
//----

Yay! Or even better:
//----
alias msecs = dur!"msecs"
...
Thread.sleep(100.msecs); //Wow. Talk about expressive !!!
//----

Sweet-o! How much cooler can this get?

...

Well, if you are compiling with "-property", the compiler forces 
you to type:
//----
Thread.sleep(100.msecs());
//----

It is *almost* the same thing, but actually not the same at all. 
It shatters the "native" feeling of the suffix notation.

AFAIK, the "-property" switch enforces that non-property 
functions use parenthesis, so removing an "@property" attribute 
is potentially breaking. The opposite though is not so true. You 
can add @property to anything, and never break code.

...

So I thought I'd discuss: Would there be a reason to not make dur 
a property? This should impact no-one, but make ufcs usage that 
much more convenient. Can I get the go-ahead to make and document 
the change?

What about making things like msecs public aliases? How do you 
feel about that?


More information about the Digitalmars-d mailing list