how to implement a function in a different D source file

Omar zelux at gmx.us
Tue Nov 26 03:06:52 UTC 2019


Hey, I'm very interested in this programming language, I already 
prefer it to C++ and if only i had adopted it years ago, but 
that's beside the point.

I read a bunch of tuts today and the only thing I'm really stuck 
on at the moment is how to actually implement a function in a 
different file.

the page here https://dlang.org/spec/function.html
suggests you can implement a function in a different file, and a 
different tutorial somewhere else (or maybe the same site or even 
same page idr) mentioned the endeavour of no-bodied-functions as 
a way of presenting a black-box type of interface.

But with the whole module namespace thing I'm a bit at a loss how 
to do this.
Say I have main.d ex.d and ex2.d and I want to import ex, and 
call a function it
declares, and implement the function in ex2.d and link the 
objects at the end so the linker is happy. I don't know how to do 
this and I can't find a straigh answer anywhere or any examples.

so ?


More information about the Digitalmars-d-learn mailing list