[comp.lang.ada] Structure sharing

worley@compass.UUCP (Dale Worley) (12/13/88)

>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

gateley@m2.csc.ti.com (John Gateley) (12/15/88)

In article <8812131536.AA08238@galaxy.compass.com> worley@compass.UUCP (Dale Worley) writes:
>>From article <65475@ti-csl.CSNET>, by gateley@m2.csc.ti.com (John Gateley):
>>    Structural sharing is nothing more than a euphemism for hacking.  
>>    ...
>[Dale's article deleted]

I would like to point out that it was actually William Wolfe who made the
above statement, not me! I am a die hard lisper: I am all for garbage
collection.

John