Don Wrote:

> Jeremie Pelletier wrote:
> > David Gileadi Wrote:
> > 
> >> Daniel Keep wrote:
> >>> Jeremie Pelletier wrote:
> >>>> If a function has both an asm and D implementations inside its body, and 
> >>>> the D version can be executed at compile time, but the asm one is much 
> >>>> faster at runtime. Is it possible to have the compiler use the D code 
> >>>> path at compile time (ie to fill in enums and whatnot), and have the asm 
> >>>> version available at runtime.
> >>> Not that I know of.  There's no way to switch based on run time/compile
> >>> time.  This was going to be solved, at least in part, using static
> >>> arguments, but that got dropped.
> >>>
> >>> As it stands, you just have to use a suffix or prefix or something to
> >>> distinguish CTFE methods from runtime methods.
> >> Is this a case for version(CompileTime){}?
> > 
> > No because it would also compile this block into the binary. 
> 
> I think something like this might work:
> 
> static if (__traits(CompileTime)) {
>     ... // ctfe code
> } else {
>     asm {
>       ...
>     }
> }
> 
> Not sure what the exact syntax should be.

Good idea, I agree with the use of __traits here. The syntax looks great to me 
as it is.

Reply via email to