From: Matthew Heaney <matthew_heaney@acm.org>
Subject: pointers & OOP
Date: 1999/05/01
Date: 1999-05-01T00:00:00+00:00 [thread overview]
Message-ID: <m3k8uszln5.fsf@mheaney.ni.net> (raw)
John Robinson <john@jr-and-assoc.demon.co.uk> writes:
> It is difficult to do anything really useful with Ada 95 OOP features
> without the use of pointers.
No. For example, a factory method in Ada95 returns an object by-value:
procedure Print (Stack : in Root_Stack'Class) is
Iterator : Root_Iterator'Class := Get_Iterator (Stack);
begin
while not Is_Done (Iterator) loop
Put (Get_Item (Iterator));
Advance (Iterator);
end loop;
end Print;
Function Get_Iterator is a (dispatching) factory method that returns an
object whose type is class-wide. The iterator object goes in the stack.
No heap is used. Is_Done, Get_Item, Advance, are all dispatching
operations.
This is an example of what Jean-Pierre was talking about. No heap, no
pointer.
> Any collection class for example will need to use pointers, even if
> the collection is based around a fixed length array.
Yes, a collection whose items have a class-wide type will require
pointer use. But you can use a smart pointer, so you don't have to
worry about any pointer manipulation headaches. Gives you the same as a
reference in other OO languages.
> Having said that, Ada still provides a more predictable OO environment
> with better compile time checking than other OO languages (that should
> get the Java crowd going :-)).
I don't think they'd disagree that Ada95 has better compile time
checking. The argument is, How important is compile-time checking to
the programmer?
Most programmers are oblivious to the benefits of rigorous compile-time
checking, and many programmers actually like having bugs (because they
get to find them and fix them), so "Ada95 has better checking" is a
tough sell.
For some ideas on smart pointers, how to control instance creation, etc,
peruse the articles (mostly Oct/Nov 98 to the present) in the Ada95
design patterns archive at the ACM.
<http://www.acm.org/archives/patterns.html>
Matt
next reply other threads:[~1999-05-01 0:00 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-05-01 0:00 Matthew Heaney [this message]
1999-05-01 0:00 ` pointers & OOP Matthew Heaney
1999-05-03 0:00 ` John Robinson
1999-05-03 0:00 ` Samuel Mize
1999-05-04 0:00 ` Robert Dewar
1999-05-04 0:00 ` Martin C. Carlisle
1999-05-04 0:00 ` Robert Dewar
1999-05-04 0:00 ` Mike Silva
1999-05-05 0:00 ` John Robinson
1999-05-05 0:00 ` Matthew Heaney
1999-05-05 0:00 ` Robert Dewar
1999-05-05 0:00 ` John Robinson
1999-05-06 0:00 ` Brian Rogoff
1999-05-07 0:00 ` dennison
1999-05-07 0:00 ` Brian Rogoff
1999-05-10 0:00 ` dennison
1999-05-11 0:00 ` Jean-Pierre Rosen
1999-05-11 0:00 ` dennison
1999-05-10 0:00 ` John Robinson
1999-05-14 0:00 ` Matthew Heaney
1999-05-14 0:00 ` David Botton
1999-05-14 0:00 ` Matthew Heaney
1999-05-14 0:00 ` Ed Falis
1999-05-05 0:00 ` Robert Dewar
1999-05-08 0:00 ` Ehud Lamm
1999-05-06 0:00 ` Simon Wright
1999-05-06 0:00 ` John Robinson
1999-05-08 0:00 ` Simon Wright
1999-05-10 0:00 ` John Robinson
1999-05-06 0:00 ` Tom Moran
1999-05-06 0:00 ` John Robinson
1999-05-06 0:00 ` Tom Moran
1999-05-07 0:00 ` dennison
1999-05-07 0:00 ` dennison
1999-05-07 0:00 ` dennison
1999-05-10 0:00 ` John Robinson
1999-05-14 0:00 ` Matthew Heaney
1999-05-05 0:00 ` Francois Godme
-- strict thread matches above, loose matches on Subject: below --
1999-05-01 0:00 Tom Moran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox