[comp.sw.components] Assignment in Ada

billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe, 2847 ) (09/24/89)

From ted@nmsu.edu (Ted Dunning):
> but where does this leave ada?  no overloading or forbidding
> assignment leaves the writer of a reliable reference counting adt in a
> real pickle.

    The fact that it is not possible in Ada 83 to overload ":=" has
    not posed practical difficulties, since it is standard practice
    to simply require the generic parameter structure

       with procedure Assign (Target : in out Object_Type;
                              Source : in     Object_Type) is <>;

    thus substituting "Assign" for ":=" in a straightforward way.

    There remains a technical problem in that we can't use "Assign"
    to initialize variables at the moment of creation, which is probably
    why this is one of the more popular Ada 9X revision requests.  

    I wouldn't use either form of assignment to do a reference-counting
    system, though... it's too easy to create unkillable garbage if one
    process dies while still holding claim to a reference. 


    Bill Wolfe, wtwolfe@hubcap.clemson.edu

ted@nmsu.edu (Ted Dunning) (09/24/89)

In article <6556@hubcap.clemson.edu> billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe, 2847 ) writes:


       I wouldn't use either form of assignment to do a
       reference-counting system, though... it's too easy to create
       unkillable garbage if one process dies while still holding
       claim to a reference.

ok... got it.  part of the purpose of ada is to improve maintenance of
software, which implies good readability.

but this lack of := overloading means that we need to use a
procedure... but let's call it setq instead of assign.

now what is the relation of parameter passing by value (i.e.
initializing) on the reference counts in a reference counting adt?  is
there any way to catch the fact that passing a variable into a
procedure constitutes another reference?  no, you say?

and finally, why don't we just use the ada equivalent of
unwind-protect to decrement reference counts in the event a process
dies.  you say it doesn't exist and pre-processors don't exist either
and extension are outlawed?

well why didn't we just use lisp to implement our adt's?  (oh, right i
forgot about the 5% overhead for garbage collection).





--
ted@nmsu.edu
			remember, when extensions and subsets are outlawed,
			only outlaws will have extensions or subsets

billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe, 2847 ) (09/25/89)

From ted@nmsu.edu (Ted Dunning):
> let's call [Ada assignment procedure] setq instead of assign.
> 
> now what is the relation of parameter passing by value (i.e.
> initializing) on the reference counts in a reference counting adt? 

   The answer is that in general, there IS no "parameter passing by 
   value"!!!!! From the Ada 83 reference manual, 6.2.7:

      ...The language does not define which [parameter passing
      mechanism] is to be adopted for parameter passing, nor
      whether different calls to the same subprogram are to use
      the same mechanism.  The execution of a program is erroneous
      if its effect depends on which mechanism is selected by the
      implementation.

   This leaves the compilers free to implement parameter passing
   any way they want to.  The semantics of parameter passing are
   simply this:

      If the parameter is "in", you can read it but not write it.

      If the parameter is "out", you can write it but not read it. 

      If the parameter is "in out", you can read and write it.

      The parameter will be of the specified type, and can be
      referenced by the specified name.

      If the user does not specify a parameter value, the specified
      default value will be supplied.

      Thou shalt assume nothing else about the passing of parameters.
 
> [...] pre-processors don't exist either and extension are outlawed?

   Actually, preprocessors do exist; I believe the Classic Ada product
   (which provides inheritance and dynamic binding to the Ada O-O types)
   works via preprocessing.  However, they must be kept separate from
   any validated compiler system.
 
> well why didn't we just use lisp to implement our adt's?  

   No concept of data typing, perhaps? 


   Bill Wolfe, wtwolfe@hubcap.clemson.edu

ted@nmsu.edu (Ted Dunning) (09/26/89)

In article <6564@hubcap.clemson.edu> billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe, 2847 ) writes:

   > now what is the relation of parameter passing by value (i.e.
   > initializing) on the reference counts in a reference counting adt? 

      The answer is that in general, there IS no "parameter passing by 
      value"!!!!! From the Ada 83 reference manual, 6.2.7:

	[ ada-noise deleted ]


	 Thou shalt assume nothing else about the passing of parameters.

one of the problems is that an in parameter is still a reference which
must be accounted for.  since there is no mechanism to handle
initialization distinct from assignment, it is difficult to write a
robust reference counting collection mechanism.

another serious problem is that if in-out parameters are implemented
as copy-in/copy-out (which is legal), then the copy-out operation is
the same as a bit-wise assignment, whereas it should be overloaded
with whatever assignment semantics are appropriate for the collectable
type.

[ please don't read the following embarassingly ad hominem riposte ]

mister wolfe in the process of villifying people for having proved
their refined sensibilities by falling asleep while listening to
adaists has in fact shown that he has not himself investigated the strengths
of other approaches.  or that perhaps he could not appreciate the
purpose of constructs without having the point driven home with a
hammer (or ada reference manual).


   > [...] pre-processors don't exist either and extension are outlawed?

      Actually, preprocessors do exist; I believe the Classic Ada product
      (which provides inheritance and dynamic binding to the Ada O-O types)
      works via preprocessing.  However, they must be kept separate from
      any validated compiler system.

and thus will never be standardized or recognized by the ada community
at large?  (i.e. those who believe true ada is gospel).  or will the
situation become one of various developers (re)inventing various
language constructs and using ada as a particularly odious target
language for their latest compiler?

   > well why didn't we just use lisp to implement our adt's?  

      No concept of data typing, perhaps? 

hmmmm..... seems to me that mister wolfe hasn't done much lisp
programming if he thinks that lisp has no concept of data typing.
perhaps he should read CLtL a bit.  particularly chapter 2 (data
types), chapter 4 (type specifiers), section 6.2 (data type
predicates), chapter 9 (declarations), as well as chapters 12, 13, 14,
15, 16, 17, 18 and 19 which describe the builtin data types and type
extension methods available to the common lisp programmer.


of course, since mister wolfe is so wonderfully omniscient, he will
know that CLtl is the commonly used abbreviation for Common Lisp, the
Language by guy steele.  


he should also consider the reasonable assertion that ml is in fact a
dialect of lisp.  where does acceptance of this put his insistence
that lisp has no concept of data typing.  in comparison, ada's
concepts of typing are very feeble indeed.


--
ted@nmsu.edu
			remember, when extensions and subsets are outlawed,
			only outlaws will have extensions or subsets