C to Pascal Conversion (Was: Pascal to C Conversion)
Duncan Murdoch
dmurdoch at watstat.waterloo.edu
Mon Feb 12 05:40:59 AEST 1990
In article <1990Feb10.231432.27149 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>In article <6263 at ncar.ucar.edu> hpoppe at bierstadt.scd.ucar.edu (Herb Poppe) writes:
>>How about the flip side of the coin? Does anyone know of C to Pascal
>>translators?
>
>I'd be very surprised to hear of any, since most C programs cannot be
>translated into Pascal in any simple way. C's pointers, in particular,
>are far more powerful than Pascal's and there is no easy way to fake them.
Do you think so? Perhaps you're talking about standard Pascal; Turbo Pascal
lets pointers be used almost as loosely as C does. Certainly there's no
built in operator to increment one, but it would be very easy to write one:
inc(longint(rec_ptr),sizeof(rec));
would come close if you didn't need to worry about crossing segment boundaries.
A bigger problem would be the growth in a program if it were translated.
Assignments must all be done in separate statements in Pascal (unless you
define an assignment function), and Turbo Pascal doesn't support macros
the way C does, so they'd all have to be expanded before translation.
Of course, the biggest problem of all would be that the Pascal program would
end up just as unreadable as the C program it was translated from - even
Pascal can't make an ugly program pretty.
Duncan Murdoch
More information about the Comp.lang.c
mailing list