Am Sat, 26 Sep 2015 18:42:03 +0200
schrieb Marco Leise <[email protected]>:

> Am Sat, 26 Sep 2015 12:21:15 +0200
> schrieb Jacob Carlborg <[email protected]>:
> 
> > On 2015-09-26 06:27, Manu via Digitalmars-d wrote:
> > 
> > > We _really_ need attribute aliasing in
> > > some form, especially since LDC/GDC have compiler-specific
> > > attributes that DMD doesn't recognise.
> > 
> > I'm not sure how much this helps but can't you use a dummy UDA on
> > DMD for the GDC/LDC attributes?
>  
> pragma(inline, true) void foo()
> @gcc.attribute.attribute("forceinline")
> @ldc.attribute.attribute("alwaysinline") @safe pure nothrow @nogc
> { // Ok, what did I want this to do again ... ? }
> 

module myinline;

static if(WhateverConditionIWant || SomeOtherCondition)
{
    struct forceinline {} //no-op
}
else
{
    version (GNU)
    {
        alias forceinline = gcc.attribute.attribute("forceinline");
    }
    else version (LDC)
    {
        alias forceinline = ldc.attribute.attribute("alwaysinline");
    }
    else version (DMD)
    {
        alias forceinline = pragma... //Damn, DMD!
    }
}

@forceinline @safe pure nothrow @nogc foo()
{
   
}

> Maybe the compiler devs can decide on more common syntax like
> a generic core.attribute or just use pragma for inlining, but
> extend it so that it offers more options:
> 
> * no
> * force
> * flatten
> (And maybe an additional 'allow' that convinces the compiler
>  that inlining is safe.)
> 

We proposed implementing a generic core.attribute for some time now
but the DMD devs weren't very enthusiastic about this. 

If you ask me, we should get rid of pragmas wherever possible. UDAs do
look better, are composable and just like pragmas do not pollute
namespaces. (@mangle("foo") instead of pragma(mangle, "foo")...

One thing missing though is UDAs for modules.

Reply via email to