Modula2's godawful IO.
Avi Bloch
avi at taux01.UUCP
Mon Apr 11 22:15:20 AEST 1988
>
>I hate C as much as the next guy, but it seems to me that printf is
>the solution. Has anyone ever written some kind of front end for a
>modula compiler to turn printf's into WriteSh*t's?
Another, more general solution, is the one we took when developing National's
Modula-2 compiler. We wanted to be able to interface with any C routine, even
those that weren't as strict as Modua-2 routines (e.g. num. & type of parameters
procedure or function, etc.). The following is an excerpt from the manual on the
extension we added for this purpose:
PSEUDO-MODULE 'C'
-----------------
A pseudo-module 'C' has been implemented which, like the pseudo-module SYSTEM
does not actually exist but is built into the compiler. Module C is used to
import C routines that cannot be defined using a Modula-2 definition, e.g.
routines that have a variable number of parameters (see following example).
Objects imported from module C have the following properties:
- The object must be a procedure.
- No type-checking is done on parameters to such procedures.
- The procedures can receive any number of pararmeters.
- The procedures can be called using either a procedure call or a function
call.
- Values returned by such procedures are of type WORD.
Example:
Give the IMPORT statement:
FROM C IMPORT printf;
all of the following statements are legal:
printf;
printf(string, integer, longreal);
cardinal = printf(string, integer, longreal);
More information about the Comp.lang.c
mailing list