home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 20048 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.8 KB  |  62 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!mcsun!sunic!liuida!isy!isy!ingemar
  3. From: ingemar@isy.liu.se (Ingemar Ragnemalm)
  4. Subject: Re: Think Pascal->C conversion -- advice?
  5. Message-ID: <ingemar.724696614@isy>
  6. Sender: news@isy.liu.se (Lord of the News)
  7. Organization: Dept of EE, University of Linkoping
  8. References: <1992Dec18.021125.23146@afterlife.ncsc.mil>
  9. Date: 18 Dec 92 16:36:54 GMT
  10. Lines: 50
  11.  
  12.  
  13. mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
  14.  
  15. >   I'm in the process of converting a large, complex program written with
  16. >Think Pascal to Think C.  I'm pretty fluent in both Pascal and C, and
  17. >programming the Mac, but I was curious if anyone else has done this and
  18. >what types of problems they ran into, or what types of things I should be
  19. >careful about.
  20.  
  21. Why do you want to do such a thing anyway? If it's speed you are after,
  22. save your time and write some optimized assembly stuff and link in as
  23. a library. I mean, Think Pascal code is not slow, as far as I can tell
  24. it's as fast as Think C.
  25.  
  26. >   I am not the primary author of this code, so I'm not very familiar with
  27. >it, which puts me at a disadvantage.  It's also quite large.
  28.  
  29. >   Some things I see that might be a problem are translating things such as
  30. >packed arrays of boolean (in Pascal, which I believe are 1-bit in size) yo
  31. >something equivalent in C.  (I can't use integers to represent booleans,
  32. >because 2 (or 4) bytes is much too large for something that only takes a bit.
  33. >Think C has a Boolean data type -- but this isn't part of ANSI C, is it?
  34. >This code needs to be ANSI-C compliant.)  That's probably not a major hurdle,
  35. >but it's little things like that which pop up and make me more cautious.
  36.  
  37. I hope you are using prototypes, or you will give yourself lots of headaches.
  38. I usually go the other way around, translating C to Pascal, and Pascal
  39. nicely catches all references that are different. C without prototypes
  40. will just crash.
  41.  
  42. Special types might be a problem in some cases, but usually not. There are
  43. lots of small things that will make life hard for you, like C's inability
  44. to hide local procedures from the rest of the program, and it's different
  45. string format. As long as you are not too dependent on the size of
  46. variables (due to file formats or resource formats), translating is
  47. quite possible. (Actually, it's harder to port a Unix program to Think C
  48. than it is to translate Think C to Think Pascal.) BTW, don't forget to
  49. declare callback routines (scrollbars, sound manager) as "pascal".
  50.  
  51. I think translating code snippets or reuseable libraries between the
  52. languages can be worthwhile, but translating a big program from Think
  53. Pascal to Think C is a waste of time.
  54.  
  55. Well, just a few ideas. Take them for what they are worth.
  56.  
  57. -- 
  58. Ingemar Ragnemalm
  59. Dept. of Electrical Engineering         ...!uunet!mcvax!enea!rainier!ingemar
  60.                   ..
  61. University of Linkoping, Sweden         ingemar@isy.liu.se
  62.