On 15 July 2013 11:46, Iain Buclaw <[email protected]> wrote: > But for floor and ceil, at least one of the following must be > available in CTFE to allow setting bits. > > ---- > // Cannot convert &real to ushort* at compile time > real y = x; > ushort* sh = cast(ushort*)&y; >
Yeah. The problem with this, is that what happens if somebody stores the pointer? It introduces loads of special cases. The most minimal solution would be to explicitly allow: ushort e = *(cast ushort *)&y; *(cast ushort *)&y = e; and likewise for getting the raw mantissa into a ulong. Simply two permissible reads, and two permissible writes, and only for x86. Essentially provides .exp | sign, and .mantissa as writable properties, but without syntax sugar. We could wrap it in a library to create syntax sugar. It's really a hack, but this is one of those low-level primitives that needs to be provided as a special case, it's kind of an __asm feature. I think the special case nature of this is unavoidable, it creates a host of problems if you allow general casting. We need it for doing atof() at compile-time, too, so providing built-in ceil and floor is not an option.
_______________________________________________ dmd-internals mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/dmd-internals
