Re: Calling D from C, C++, Python…

2015-09-13 Thread Jakob Ovrum via Digitalmars-d-learn
On Thursday, 10 September 2015 at 18:01:10 UTC, Russel Winder wrote: Is there an easy way of knowing when you do not have to initialize the D runtime system to call D code from, in this case, Python via a C adapter? I naïvely transformed some C++ to D, without consideration of D runtime

Re: Calling D from C, C++, Python…

2015-09-13 Thread Jakob Ovrum via Digitalmars-d-learn
On Sunday, 13 September 2015 at 10:10:32 UTC, Jakob Ovrum wrote: On Thursday, 10 September 2015 at 18:01:10 UTC, Russel Winder wrote: Is there an easy way of knowing when you do not have to initialize the D runtime system to call D code from, in this case, Python via a C adapter? I naïvely

Re: Calling D from C, C++, Python…

2015-09-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-09-13 12:10, Jakob Ovrum wrote: On Linux and other ELF-using platforms, initialization and deinitialization functions could be placed in the .init and .deinit special sections, but I don't know if druntime has any convenient provisions for this. With GDC and LDC you can probably use a

Re: Calling D from C, C++, Python…

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 09:47:55 UTC, Jacob Carlborg wrote: Well, if your D function doesn't use anything of the runtime I guess it's not necessary. Right. If you don't call into the threading system in the druntime, you should be ok. Keep in mind though that the GC uses the

Re: Calling D from C, C++, Python…

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 18:20:37 UTC, Brad Roberts wrote: You can get away with it in some circumstances, but it's at your own risk. Yeah, I agree.

Re: Calling D from C, C++, Python…

2015-09-12 Thread Brad Roberts via Digitalmars-d-learn
On 9/12/15 9:20 AM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Saturday, 12 September 2015 at 09:47:55 UTC, Jacob Carlborg wrote: Well, if your D function doesn't use anything of the runtime I guess it's not necessary. Right. If you don't call into the threading system in the druntime,

Re: Calling D from C, C++, Python…

2015-09-12 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2015-09-11 at 21:50 +0200, Jacob Carlborg via Digitalmars-d -learn wrote: > On 2015-09-10 20:01, Russel Winder via Digitalmars-d-learn wrote: > > Is there an easy way of knowing when you do not have to initialize > > the > > D runtime system to call D code from, in this case, Python via a

Re: Calling D from C, C++, Python…

2015-09-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-09-12 10:56, Russel Winder via Digitalmars-d-learn wrote: I have a small D function (C linkage) compiled to a shared object that I am calling from Python via CFFI that works fine with no D runtime initialization. Thus I have experimental evidence "always" is not entirely the case! I

Re: Calling D from C, C++, Python…

2015-09-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-09-10 20:01, Russel Winder via Digitalmars-d-learn wrote: Is there an easy way of knowing when you do not have to initialize the D runtime system to call D code from, in this case, Python via a C adapter? You always need to initialize the D runtime, unless you have a D main function.

Calling D from C, C++, Python…

2015-09-10 Thread Russel Winder via Digitalmars-d-learn
Is there an easy way of knowing when you do not have to initialize the D runtime system to call D code from, in this case, Python via a C adapter? I naïvely transformed some C++ to D, without consideration of D runtime systems, compiled it and it all worked. Which is good, but… -- Russel.