🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2066

Re: C's sins of commission

#2066
From: Darren New
Date: Wed, 14 Nov 1990 22:40
45 lines
3251 bytes
There aer two uses for pointers that heiarchical data structues do not seem
to addess, but which are nonetheless vey useful. 

1) changing one object into another.  Smalltalk supports this with the 
  "become:" operator.  Basically, "A become: B" makes all references to
  B now be references to A and vica versa.  I imagine that this could be
  done with the aliasing that is proposed in Hermes. (BTW, is there a 
  reference to whee I could learn more about Hermes?)  However, in Smalltalk,
  this is almost invaiably used in one of two situations: 
  a) Objects have a fixed size once created. To add more elements to a set (A),
     make a new set (B) which is larrger, copy A into B, and then "A become: B".
  b) To break circular dependancies for the garbage collector. That is,
     "bigStructureWithPossiblyCircularPointerSomewhere become: String new"
     will cause all references to that structure to be replaced with something
     which has no out-going references, hence allowing it to be GCed even if
     through some bug you have accidentally not discarded the path from
     the root diectory to the circular structure.  You may get errors later
     because the bigStructure... does not handle the same messages as
     Strings do, but it's better than having all that hanging around forever
     because of a programming mistake.

2) iterating over all objects (or all objects of a certain type). For example,
   it is not uncommon to have code to iterate over all objects that reference
   object X, or to iterate over all functions that have a reference to
   a paticular global variable, or whatever.  Unless you can declare a 
   vaiable that can be aliased to *any* value of a particular type (in which
   case I would call that variable a pointer), this extreamly handy operation 
   cannot be handled in Hermes. This is useful when making global munges
   of in-core data (like when adjusting the format of data). It is also useful
   when there is a rare or unplanned operation in which the natural 
   structuring of the data is not appropriate, which happens in relational
   databases all the time. For example, it is rare to ask "find all functions
   with the string 'xyzzy' in the comment field" or "find all source files
   holding a function which contains a local variable whose name ends in 'W'".
   It would be silly to build such things into the data structure repesenting
   compiled code, but the ability to iterate over source files, functions,
   and so on makes it possible.

			     -- Darren
			     (All typos to be blamed on an old Z19)

-- 
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages, 
      Formal Description Techniques (esp. Estelle), Coffee -----
Technical Details
Message-ID: <36366@nigel.ee.udel.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!ee.udel.edu
References: <27376@megaron.cs.arizona.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!ee.udel.edu
From: new@ee.udel.edu (Darren New)
Newsgroups: comp.lang.misc
Subject: Re: C's sins of commission
Message-ID: <36366@nigel.ee.udel.edu>
Date: 14 Nov 90 22:40:31 GMT
References: <27376@megaron.cs.arizona.edu>
Sender: usenet@ee.udel.edu
Organization: University of Delaware
Lines: 45
Nntp-Posting-Host: snow-white.ee.udel.edu