From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_20,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!ucbvax!compass.UUCP!worley From: worley@compass.UUCP (Dale Worley) Newsgroups: comp.lang.ada Subject: Structure sharing Message-ID: <8812131536.AA08238@galaxy.compass.com> Date: 13 Dec 88 15:36:49 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: >>From article <65475@ti-csl.CSNET>, by gateley@m2.csc.ti.com (John Gateley): > Structural sharing is nothing more than a euphemism for hacking. > It is the spatial equivalent of what hackers enjoy doing with time > in the name of efficiency, in their unmitigated zeal to violate every > form of abstraction, to throw all traces of readability and reliability > to the winds. I find this comment somewhat strange. Structure sharing is at the least a useful tool. Consider computations in Lisp, in which the default mechanisms for composing and decomposing lists involves structure sharing. Or again, consider a somewhat object-oriented application, where you want the person-record for John Smith to be a member of both the list-of-people-who-work-for-XYZ-Corp. and the list-of-people-who-live-in-Jonesville, so that both his paycheck and his property tax bill affect the *same* bank balance. I would hazard that readability and reliability are not worse than with any other paradigm for dealing with complicated dynamic data structures, and are probably better, if my experience with Lisp is typical. Of course, to prevent chaos (violation of abstraction), one must be careful in using structure sharing. For instance, the Lisp style of casual structure sharing only works well if the structures are read-only, that is, a structure is changed only by building a new, changed copy that shares the unchanged parts. (This is easy and often efficient in Lisp.) There are tales of insidious bugs caused by programmers modifying lists in-place, only to discover that some other variable was sharing that structure. But, structure sharing can be a very useful device for expressing computations, and sometimes is almost necessary to clearly express the essence of the computation. Whether it is useful for the sort of programs Ada is intended for is a question I leave to the experts. I will add that garbage collection is one of the greatest aids to readabilty and reliability, because it takes a complicated and error-prone part of programming (reclaiming storage) and eliminates it completely. It probably shouldn't be required in Ada, but as an aid in programmability, it's great. Dale -- Dale Worley, Compass, Inc. mit-eddie!think!compass!worley