🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #87

Calling C from Modula (was Re: Modula-2 in the real world)

#87
From: Cris Fuhrman
Date: Mon, 30 Mar 1992 08:56
37 lines
2178 bytes
In article <11265.29D38335@puddle.fidonet.org>
Jon.Guthrie@p25.f2000.n106.z1.fidonet.org (Jon Guthrie) writes:
>In a message on <Mar 23 22:13>, Lawrence D'Oliveiro, Waikato Univer (1:105/42)
writes:
>
> >> C has inexpensive "third-party" libraries that make many things 
> >> simpler.  Modula has none of these.
>
> >But can't you use the C ones? Both the Modula-2 compilers that I 
> >have used at all heavily had the ability to link with external code. 
> >All you'd have to do is create appropriate definition modules to interface 
> >to the libraries. 
>
>I don't think you've ever done this or you'd know that it isn't this simple.  
...
>  It's a LOT simpler to write 
>Modula-2 routines to run under C programs than it is the other way around.  
>The upshot of all this is that while it CAN be done, it's not worth the
effort.

I'd just like to say that I've been using CCALL (to C library routines) within
the Sun Modula environment and it works quite well and is very practical,
provided you make sure to pass the correct types to C. It requires a good
understanding of both languages (i.e. C has no VAR parameters explicitly so you
have to be careful).

Another nice thing with the Modula for the Sun is that you can define Modula
interfaces to other languages (C included) so that you can do type checking of
the parameters of a call, and you have code that looks like Modula, not like
code full of ugly CCALLs (which look like CCALL('printf','the value of x =
%i',x); ).

-Cris Fuhrman
fuhrman@litsun.epfl.ch
Laboratoire Informatique Technique
Ecole polytechnique federale de Lausanne
Lausanne Switzerland
Technical Details
Message-ID: <3453@disuns2.epfl.ch>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!chx400!sicsun!disuns2!litsun.epfl.ch
References: <11265.29D38335@puddle.fidonet.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!chx400!sicsun!disuns2!litsun.epfl.ch
From: fuhrman@litsun.epfl.ch (Cris Fuhrman)
Newsgroups: comp.lang.modula2
Subject: Calling C from Modula (was Re: Modula-2 in the real world)
Message-ID: <3453@disuns2.epfl.ch>
Date: 30 Mar 92 08:56:22 GMT
References: <11265.29D38335@puddle.fidonet.org>
Sender: news@disuns2.epfl.ch
Reply-To: fuhrman@litsun.epfl.ch
Organization: Ecole Polytechnique Federale de Lausanne
Lines: 37
Nntp-Posting-Host: litmac89.epfl.ch