C to Pascal translation.

Dave Trissel davet at oakhill.UUCP
Sun Dec 23 04:51:06 AEST 1984


<.......>
In article <437 at gitpyr.UUCP> robert at gitpyr.UUCP (Robert Viduya) writes:
>> 
>> 	union u {
>> 		int (*f)();
>> 		char *c;
>> 	} u;
>> 	h() {
>> 		u.c = "foo";
>> 	}
>> 	g() {
>> 		u.f = h;
>> 	}
>> 	main () {
>> 		g();
>> 		(*u.f)();
>> 		printf("%s\n", u.c);
>> 	}
>> 
>> If you make some restrictions, then it can sort of be done.
>
>Actually, the restriction is not in the unions.  Pascal can handle the
>concept of unions by using variant records with no tag field specifier.
>The restriction of translating C to Pascal is that Pascal does not support
>pointers to functions.
>Robert Viduya

Modula-2 does.  Note that Modula-2 also handles string ala "C" with a zero
terminator byte.

Motorola Semiconductor                             Dave Trissel
Austin, Texas          {ihnp4,seismo,gatech,ctvax}!ut-sally!oakhill!davet



More information about the Comp.lang.c mailing list