www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Interfacing D with C and Fortran

reply data pulverizer <data.pulverizer gmail.com> writes:
Hi All,

 9il and I have written a D blog article titled "Interfacing D 
with C and Fortran" which is located here: 
https://github.com/dataPulverizer/interface-d-c-fortran. We would 
greatly appreciate feedback from the D community before we 
publish it.

Many thanks in advance.

DP
Apr 04
next sibling parent reply jmh530 <john.michael.hall gmail.com> writes:
On Tuesday, 4 April 2017 at 13:25:27 UTC, data pulverizer wrote:
 Hi All,

  9il and I have written a D blog article titled "Interfacing D 
 with C and Fortran" which is located here: 
 https://github.com/dataPulverizer/interface-d-c-fortran. We 
 would greatly appreciate feedback from the D community before 
 we publish it.

 Many thanks in advance.

 DP
I liked it. Here are my thoughts: In some cases, there were bits that I don't follow as well like where you have $ nm example1.o and its results You might want to highlight that betterC is not well documented and provide a few more details on what it means, what are the limitations, etc. You wrote an apply function. Is phobos' map not compatible with betterC? Maybe mention that mir has a map function in ndslice algorithm that could be a betterC alternative. You also discuss template alias parameters when talking about apply. Template aliases seem a bit like magic to me. Sure, I've used them, but still seem like magic. And I don't think the D docs do a great job explaining it. Maybe give a short explanation in addition to what is there (perhaps as a footnote?).
Apr 04
parent data pulverizer <data.pulverizer gmail.com> writes:
Thanks for the constructive feedback! Glad you liked the article.

On Tuesday, 4 April 2017 at 15:40:49 UTC, jmh530 wrote:
 I liked it. Here are my thoughts:

 In some cases, there were bits that I don't follow as well like 
 where you have
 $ nm example1.o
 and its results
You're right some more explanation here would be useful
 You might want to highlight that betterC is not well documented 
 and provide a few more details on what it means, what are the 
 limitations, etc.
True, there isn't a lot of material around about this flag and I'd appreciate some more details from those "in the know", 9il knows more about this than I do.
 You wrote an apply function. Is phobos' map not compatible with 
 betterC? Maybe mention that mir has a map function in ndslice 
 algorithm that could be a betterC alternative.
9il and I agreed that we would keep this article dependency free but we can include links to those alternatives.
 You also discuss template alias parameters when talking about 
 apply. Template aliases seem a bit like magic to me. Sure, I've 
 used them, but still seem like magic. And I don't think the D 
 docs do a great job explaining it. Maybe give a short 
 explanation in addition to what is there (perhaps as a 
 footnote?).
Wow a footnote! This might look like a real article :-) That was a joke! We can add a short description with links. I think a detailed article can be written on template alias parameters alone. Thanks a lot for your feedback. It is much appreciated
Apr 04
prev sibling parent reply bachmeier <no spam.net> writes:
On Tuesday, 4 April 2017 at 13:25:27 UTC, data pulverizer wrote:
 Hi All,

  9il and I have written a D blog article titled "Interfacing D 
 with C and Fortran" which is located here: 
 https://github.com/dataPulverizer/interface-d-c-fortran. We 
 would greatly appreciate feedback from the D community before 
 we publish it.

 Many thanks in advance.

 DP
Unless I missed it, there is no mention of iso_c_binding for Fortran. That is worth at least a mention, because - It is documented well and handles many of the underlying details. - It creates a C interface that can then be called from D like a C function. - The target audience of this article includes C programmers already calling into Fortran using iso_c_binding. There's no reason for them to think they have to learn something new to switch to D. I haven't used Fortran in some time, but when I did call it from C, iso_c_binding was very helpful.
Apr 04
parent data pulverizer <data.pulverizer gmail.com> writes:
On Tuesday, 4 April 2017 at 16:20:56 UTC, bachmeier wrote:
 Unless I missed it, there is no mention of iso_c_binding for 
 Fortran. That is worth at least a mention, because

 - It is documented well and handles many of the underlying 
 details.
 - It creates a C interface that can then be called from D like 
 a C function.
 - The target audience of this article includes C programmers 
 already calling into Fortran using iso_c_binding. There's no 
 reason for them to think they have to learn something new to 
 switch to D.

 I haven't used Fortran in some time, but when I did call it 
 from C, iso_c_binding was very helpful.
Fair point. I was in two minds about mentioning this because Fortran programmers will already know about it but including it is probably the right thing.
Apr 04