tom@ur-cayuga (04/29/86)
Subject: Modula-2 and other languages (under UNIX on VAX) Does anyone know of any Modula-2 compilers that let you call modules or functions written in other languages? What I need is a way to do things in a Modula-2 program that I can't do in Modula-2, i.e. generate certain priviledged VAX instructions (this is for the innermost layers of an operating system we are writing). We currently do this (in a Modula [NOT Modula-2] PDP-11 compiler) with "code escapes" which allow one to embed assembly language directly in the source. Also, I was wondering if there is a general-purpose mechanism for linking j. random object modules with Modula-2 objects, so I could use "C" for some functions, or better yet, write a Modula-2 library module which could be linked with a "C" program, so I only have to maintain 1 run-time system. Thanks, Tom Perrine tom@logicon.arpa == Perrine@DOCKMASTER.ARPA Logicon - Operating Systems Division San Diego, CA
lmjm@doc.ic.ac.uk (04/30/86)
Both Powells compiler and one I've been working on locally use the same
trick. You write the DEFINITION module in M2 but the IMPLEMENTATION of
that module in some other language. I can't remember what the conventions
are in Powells but I have all identifier names qualified with the module
name at the begining followed by an '_'. There is also an initialisation
function for each module with the name module-name__init.
For example:
DEFINITION MODULE x;
EXPORT QUALIFIED
PROCEDURE f ( a : INTEGER ) : INTEGER;
END x;
/* implementation of x in C */
x_f( a )
int a;
{
blah blah blah
return( 0 );
}
x__init()
{
function to initialise x
call to this automatically generated by modules that import x.
}
Although this has the IMPLEMENTATION in C so long as the name
conventions (and of course the call/return conventions) are adhered to
any language can be used.
Using a M2 module from C is just as easy so long as you remember to
call module-name__init() before using it.
--
UKUUCP SUPPORT Lee McLoughlin
"What you once thought was only a nightmare is now a reality!"
Janet: lmcl@uk.ac.ukc, lmjm@uk.ac.ic.doc
DARPA: lmjm%uk.ac.doc.ic@ucl-cs
Uucp: lmjm@icdoc.UUCP, ukc!icdoc!lmjmlmjm@ivax (04/30/86)
Subject: Modula-2 and other languages (under UNIX on VAX)
Both Powells compiler and one I've been working on locally use the same
trick. You write the DEFINITION module in M2 but the IMPLEMENTATION of
that module in some other language. I can't remember what the conventions
are in Powells but I have all identifier names qualified with the module
name at the begining followed by an '_'. There is also an initialisation
function for each module with the name module-name__init.
For example:
DEFINITION MODULE x;
EXPORT QUALIFIED
PROCEDURE f ( a : INTEGER ) : INTEGER;
END x;
/* implementation of x in C */
x_f( a )
int a;
{
blah blah blah
return( 0 );
}
x__init()
{
function to initialise x
call to this automatically generated by modules that import x.
}
Although this has the IMPLEMENTATION in C so long as the name
conventions (and of course the call/return conventions) are adhered to
any language can be used.
Using a M2 module from C is just as easy so long as you remember to
call module-name__init() before using it.
--
UKUUCP SUPPORT Lee McLoughlin
"What you once thought was only a nightmare is now a reality!"
Janet: lmcl@uk.ac.ukc, lmjm@uk.ac.ic.doc
DARPA: lmjm%uk.ac.doc.ic@ucl-cs
Uucp: lmjm@icdoc.UUCP, ukc!icdoc!lmjm