Compile-time evaluation of real expressions?

Robert Clipsham robert at
Fri Jan 6 18:49:34 PST 2012

On 07/01/2012 02:28, H. S. Teoh wrote:
> On Sat, Jan 07, 2012 at 02:15:39AM +0000, Robert Clipsham wrote:
>> On 07/01/2012 00:31, H. S. Teoh wrote:
>>> I admit I've no idea how the D compiler implements compile-time
>>> evaluation, but is it possible for the compiler to actually emit code
>>> for compile-time functions containing asm blocks and, say, execute it
>>> in a sandbox, and read the values out from the machine registers? Or
>>> does this create more problems than it solves?
>> Doing this would mean you can't do cross-compilation, eg using x86 to
>> compile for ARM. Which means you'd need to use a virtual machine for
>> it, which is almost certainly more effort than it's worth.
> [...]
> But doesn't the use of asm{} already prevent cross-compilation in the
> first place? Or does the D compiler actually translate the instructions
> into the target platform? In which case, doesn't it already know enough
> to be able to interpret it?
> I'm pretty sure I'm missing something obvious.
> T

version(X86) asm
   // X86 ASM
else version(ARM) asm
   // ARM ASM
// etc


More information about the Digitalmars-d-learn mailing list