The future of Haskell discussion
Eray Ozkural (exa)
erayo@cs.bilkent.edu.tr
Fri, 14 Sep 2001 18:04:24 +0300
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 14 September 2001 12:52 pm, Marcin 'Qrczak' Kowalczyk wrote:
> I think it should be easy to add support for C++, except exceptions.
>
> There are two approaches: call C++ functions directly (it requires
> implementing name mangling by the Haskell compiler; there are several
> name mangling schemes and gcc changed its scheme in version 3.0)
> or write C wrappers (this is inconvenient but is doable now without
> compiler support).
>
> An annoyance is that templates can't be called directly but each
> instance must be imported separately.
>
I understand that you ought to deal with name mangling at some stage, but how
would the interfaces ultimately look like? Say, for instance virtual
functions, classes, sub classes, constructors, destructors?
If you can do non-template C++, then it wouldn't be difficult to call
template code. Just do an explicit instantiation of the template code in an
auto-generated .cxx file. What's the problem there?
> On Linux it works when main() of a mixed C/C++ program is written in C.
> AFAIK it doesn't work everywhere. Nevertheless an example I've now
> made worked.
>
It's about the linker used I guess. You should be able to do that.
> hsc2hs and ghc need to be extended to make it work smoothly. hsc2hs
> produces a file with extension .c and ghc compiles these files by
> passing -x c options to the C compiler, so even if a C++ compiler is
> substituted, it is compiled as C. There should be a switch in hsc2hs
> to let it produce C++ and ghc should recognize .cc extension, or
> in some other way ghc should be informed that the .c file is really
> C++. Option -pgmlg++ causes ghc to link using g++; option -lstdc++
> instead also works. And hsc2hs should be taught about extern "C".
Writing another such translator would be necessary. After all, C++ is another
language. It would be quite tricky to do that. It's halfway writing a C++
front-end, and would require an amount of deep magic. Even a standard
conformant parser alone is quite difficult. Anybody give it a shot? :)
Thanks,
- --
Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr>
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B EA0F 7C07 AE16 874D 539C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE7ohx4fAeuFodNU5wRAlF9AKCnpE7xO3QzI8qeqih9coifE0Td4wCfT+gj
aOKIFCV6yu1XEB4oUHmGvI8=
=UR1s
-----END PGP SIGNATURE-----