www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - suggestion add extern(GO)

reply d007 <d007 gmail.com> writes:
golang support linker with asm without cgo at much fast speed.

 From this blog you can see go can call rust function without CGO 
https://words.filippo.io/rustgo/


maybe add extern(GO) will bring D into a large user community.

extern(GO) should only support pointer and scalar arguments, and 
must be  nogc nothrow.
Jun 06 2023
parent reply Johan <j j.nl> writes:
On Tuesday, 6 June 2023 at 15:46:00 UTC, d007 wrote:
 golang support linker with asm without cgo at much fast speed.

 From this blog you can see go can call rust function without 
 CGO https://words.filippo.io/rustgo/


 maybe add extern(GO) will bring D into a large user community.

 extern(GO) should only support pointer and scalar arguments, 
 and must be  nogc nothrow.
The way I understand the article, nothing new is needed on the D side: you use extern(C) (and -betterC if you don't want to link with druntime). -Johan
Jun 06 2023
parent d007 <d007 gmail.com> writes:
On Tuesday, 6 June 2023 at 16:54:07 UTC, Johan wrote:
 The way I understand the article, nothing new is needed on the 
 D side: you use extern(C) (and -betterC if you don't want to 
 link with druntime).

 -Johan
you are right, any extern(C) from static or dynamic library should be able to link into golang. What I like to do is like extern(C++) or extern(Objc), add extern(GO) support, generate function is able to call from go without extra trampoline. (generate syso file to link with go)
Jun 06 2023