> Has anyone thought of using Nim with Lazarus LCL or Delphi's VCL?

there are several problems here:

  * memory management
  * compatibility of standard types like string and dynamic array (=seq)
  * calling convention



The first two are feasible with the new `destructors`. I am writing a library 
which re implements Delphi strings and dynamic arrays in Nim.

The last one is the main problem here. Delphi and freepascal have their own 
calling convention register in Win32 mode which is only fully supported by C++ 
Builder and is incompatible to fastcall in other C compilers (there is a mode 
in gcc which works for up to 3 parameters) . Compiling Nim to C++ Builder is a 
constant point of frustration. And still you would need to translate the C++ 
headers to nim (and c2nim does not work here, because C++ Builder has many 
extensions to make it compatible with Delphi)

So to get it running you have to write a layer in pascal which uses `cdecl` or 
`stdcall` and exposes the whole VCL - for everything you want to access from 
Nim.

Another possibility would be to wrap the Delphi controls etc in OLE Automation 
interfaces - but again a lot of work.

So currently you can use Nim from Delphi, but it is hard to use Delphi from Nim.

Reply via email to