Things that make writing a clean binding system more difficult

Ethan Watson via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 5 01:15:37 PDT 2016


On Thursday, 4 August 2016 at 11:41:00 UTC, Jacob Carlborg wrote:
> That works for me [1]. It was reported by Manu and fixed in 
> 2012 [2].

I did some more experimenting, and it turns out that the problem 
is when the declaration and definition have different linkage. 
Being C++ functions means that all the functions are declared 
with extern( C++ ), but the mixin generates essentially extern( D 
) functions.

And a bit more prodding and poking, and I found some problems 
with UDAs - specifically, adding them in the declaration but not 
having them in the definition. We use UDAs extensively to mark up 
functions for binding. Depending on when my function collector 
template instantiates at compile time determines whether I can 
see the UDAs or not.

So that's technically a bug. But. Before I go running off to the 
Bugzilla Walter made. Should a user declaring and then later 
defining a function be forced to 100% replicate that function 
definition before defining it? If yes, then the compiler needs to 
error. If no, then there'll need to be some rules made up for it 
because I can already see how that will be open to abuse.


More information about the Digitalmars-d mailing list