home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16109 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  2.6 KB

  1. Xref: sparky comp.lang.c++:16109 comp.std.c++:1538
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!charon.amdahl.com!pacbell.com!network.ucsd.edu!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  4. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  5. Subject: Re: PROPOSAL: Hidden private parts of classes
  6. Message-ID: <1992Nov11.181520.12692@ucc.su.OZ.AU>
  7. Sender: news@ucc.su.OZ.AU
  8. Nntp-Posting-Host: extro.ucc.su.oz.au
  9. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  10. References: <klamer.720538594@mi.el.utwente.nl> <1992Nov7.155248.23401@ucc.su.OZ.AU> <klamer.721303355@mi.el.utwente.nl>
  11. Date: Wed, 11 Nov 1992 18:15:20 GMT
  12. Lines: 47
  13.  
  14. In article <klamer.721303355@mi.el.utwente.nl> klamer@mi.el.utwente.nl (Klamer Schutte) writes:
  15. >In <1992Nov7.155248.23401@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  16. >
  17. >]In article <klamer.720538594@mi.el.utwente.nl> klamer@mi.el.utwente.nl (Klamer Schutte) writes:
  18. >
  19. >]>OK, that holds for global / static variables. But how for auto variables?
  20. >]>These generally are efficient to use, but to be efficient, their size
  21. >]>must be known at compile time. 
  22. >
  23. >]    Why? Why cant the size be calculated by a smart linker
  24. >]at link time? Why cant assembly output be made by the compiler
  25. >]with 'sizeof_someobject' as a symbol yet to be determined?
  26. >
  27. >]>and thus can only a pointer to an object on the heap be used.
  28. >
  29. >]    NO, and I have SEEN it done otherwise in a Modula compiler,
  30. >]I used it and it worked.
  31. >
  32. >I doubt it. I can't see how a compiler can build a stack frame with
  33. >auto variables, if the sizes of the elements on the stack frame are
  34. >unknown. 
  35.  
  36.     The Modula compiler looks up the last definition of the type
  37. and uses the size of that. If subsequently the system finds that
  38. its been changed, auto-dependency checking causes the module
  39. to be re-compiled.
  40.  
  41.     As I said before this requires environment support to
  42. work, and is unlikely to be workable for C++ which doesnt have
  43. the ability to pre-compile a class interface declaration.
  44. Modula has separate INTERFACE and IMPLEMENTATION sections
  45. for modules and it is possible to do this. Modula *requires*
  46. environment support because it has a USE MODULENAME statment,
  47. whereas C has #include filename. Modula has to associate
  48. the internal MODULENAME with an external file containing
  49. the precompiled module interface anyhow.
  50.  
  51.     So thats how it works. It was done deliberately to
  52. avoid using a pointer on the stack.
  53.  
  54.  
  55.  
  56. -- 
  57. ;----------------------------------------------------------------------
  58.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  59.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  60. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  61.