[phobos] Proposal of StopWatch module
David Simcha
dsimcha at gmail.com
Thu Aug 19 20:50:56 PDT 2010
On 8/19/2010 11:44 PM, Andrei Alexandrescu wrote:
> On 08/19/2010 09:47 PM, Brad Roberts wrote:
>> On Thu, 19 Aug 2010, Andrei Alexandrescu wrote:
>>>
>>> As I'm sure you know we're trying to help the matter with library-based
>>> approaches, but leaving straight in the language a feature that is
>>> impossible
>>> to make safe is not admissible. Walter and I agree that scope must be
>>> abolished.
>>
>> Cast and union can't be made safe either.. should they be removed? Why
>> not push scope out of the safed subset and leave the tool around where
>> it's useful?
>
> Cast and union must stay primitives because they can't be done in a
> library. I'd remove them if I could, but doing so would strictly
> reduce the language's power.
>
> Andrei
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
Well, if you have unions you could probably do casts in a library. I'm
not saying we should do this, just that it's possible. For example:
U cast(T)(T ptr) if(isPointer!T && isPointer!U) {
union U {
T t;
U u;
}
U myUnion;
myUnion.t = ptr;
return myUnion.u;
}
More information about the phobos
mailing list