Things that make writing a clean binding system more difficult

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 28 01:49:35 PDT 2016


On 7/28/2016 1:33 AM, Ethan Watson wrote:
> 1) Declaring a function pointer with a ref return value can't be done without
> workarounds.
>
> Try compiling this:
>
> ref int function( int, int ) functionPointer;
>
> It won't let you, because only parameters and for loop symbols can be ref types.
> Despite the fact that I intend the function pointer to be of a kind that returns
> a ref int, I can't declare that easily. Easy, declare an alias, right?
>
> alias RefFunctionPointer = ref int function( int, int );

C/C++ have essentially the same problem, if you want to declare a function 
pointer parameter that has different linkage.

The trouble is there's an ambiguity in the grammar. I don't really have anything 
better than the two step process you outlined.


> ====================
> 4) Forward declaring a function prototype means I can never declare that
> function elsewhere (say, for example, with a mixin)

Do you mean:

   void foo();
   void foo() { }

?



More information about the Digitalmars-d mailing list