[phobos] Proposal of StopWatch module

SHOO zan77137 at nifty.com
Thu Aug 19 06:38:34 PDT 2010


(2010/08/19 2:38), Jonathan M Davis wrote:
> On Wednesday, August 18, 2010 10:21:56 SHOO wrote:
>>> Line 414: no need for @trusted, casting numbers is not unsafe.
>>
>> Error: cast from const(long) to real not allowed in safe code
>
> Maybe to!long will work.
>

But, to!real(long) is system function unfortunately.

>> It's my understanding that there are two reasons why a struct doesn't
>> have a default constructer toward.
>> Primarily, it can define as a variable without minding an initialization
>> method in particular generic programming.
>> Second, it ensure the initialization that resource assignment does not
>> occur.
>> See also: http://j.mp/9KGTFd
>
> According to TDPL, it's because you have to know the struct's init value at
> compile time. You can only have one init, and it's quite possible to create
> default constructors which result in different values even though they don't have
> any parameters. Classes avoid the problem because their reference-based and the
> reference itself is what gets the init. But since structs go on the stack, it
> doesn't work to have an arbitrary default constructor. It might work at some
> point to have default constructors with certain restrictions (like maybe
> purity), but for the moment, we don't have a way to make it work.
>
> - Jonathan M Davis

What is the reason why all types must have .init property?
I think that structs may not need to have .init property.

... However, I think that this is a very sensitive problem ATST.

In the first place, should we use class keyword for the classes(of OOP)?
Although there is scope class which seems to satisfy these demands, it 
does not function well.
Isn't improving scope more strongly better than marking scope deprecated?


More information about the phobos mailing list