comp.lang.ada
 help / color / mirror / Atom feed
From: aschwarz@acm.org (skidmarks)
Subject: Re: Ada Pointer Problem
Date: 7 Oct 2004 11:45:41 -0700
Date: 2004-10-07T11:45:41-07:00	[thread overview]
Message-ID: <35f054ea.0410071045.58d3e9af@posting.google.com> (raw)
In-Reply-To: ck1h34$cji$1@a1-hrz.uni-duisburg.de

Thank you for your response, most assuredly thank you for not taking
offense and starting a flame.

> 
> So maybe there is an opportunity to improve the exposition of
> Ada language constructs for programmers expecting wide spread
> terminology.
> Even if there is good reason to make the distinction
> between the _various_ pointer like things and addresses in Ada
> explicit.
> OTOH, almost every introductory chapter, starting from the beginning,
> mentions access values.
> Ada as a Second Language has a whole chapter describing access
> types. They are also mentioned in the introductory chapter, IIRC.
> Does Ada assume programmers that have had an opportunity to
> become familiar with their tool?
> 
> In order to find "pointer" in the ARM (Ada 95, admittedly)
> I pressed the search key twice for "pointer" and found:
> 
>  18. (77) Access values are called "pointers" or "references" in some
>      other languages.
> 

Ada draws sharp distinction between Ada constructs and similar
constructs in other languages. In the early years (Ada 83) this
distinction seems to have led to an abandonment of the use of common
terminology in favor of the Ada specific flavor. This resulted in my
inability to find a 'pointer'. My recollection is that the Ada 83 LRM
and 'Ada as a Second Language' have no index or table of contents
reference to 'pointer'. Looking for a pointer becomes fruitless, and
looking for an 'Access Type' works if you already know that an 'Access
Type' is what you want.

Ada 95 improves the search time for items with different Ada flavors
but with common names in other languages. Pointer is one of the
explicit references, and one which would have improved the Ada 83 LRM
and books.


> Could you give some examples?
>  

The best example is the one that prompted my original posting. Within
a subprogram I attempted to create a pointer to an object created in
the same subprogrm using a typedef imported from another spec file.
This thread shows good reasons why this is inadvisable and why such
care was spent making it impossible to do using 'Access'. My compiler
(Green Hills Version 3.5) provided not the slightest clue as to why
this happened or where to look for a rationale. My argument is that
even if the compiler had been more congenial, the language is still
tortuous. And for me, tortuous to the point of being almost unusable.
To continue the point, the Ada developers recognized both the
indavisability of doing what I wanted and the advisability of letting
me do this assignment, also mentioned in this thread and very
gratefully received by me. However, this is a research game. Ada has
protected me to the point that I can't get my job done without
research. Commmon assumptions are uncommonly treated.

Now (back to pointers) I am similarly frustrated. I want to point to
an object created on the call stack and to pass/use this pointer to my
hearts delight. However, I don't know how. Rather than belabor the
point and spending my time in research (and your time in answering
what must be almost frivolous questions), I am using heap allocation.
'Ada as a Second Language' recommends that the heap deallocator
(Unchecked_Deallocation) not be used - on fear of death no doubt.
Fortunately, this is a non-real-time program on a PC with an available
address space of 2Gb. The period of execution is small enough that
wasting space is not a problem. Hence, no Unchecked_Deallocation will
be used.

Why pointers? The compilers we are using pass by value. Arrays and
records copied to the stack on subprogram entry, and copied back on
subprogram exit (or so I have been told). A pointer reduces this copy
operation.

Pointers are useful for maintaining indirect references to volatile
data. The reference changes when the data changes, but no copy
operation is required.

Pointers are useful in lists.

And so on.

The 'point' is that the required reading to do simple, but perhaps
non-pedestrian things, is far larger than in other languages. This
intrudes on my ability to produce a product (but does not impact good
design).

Putting it another way, I can build a house with a steel hammer or a
brass hammer. If I used a brass hammer I would be required to
periodically grind it's head to make it true. The brass hammer is
shiny, bright, and a real pleasure to look at, but lacks something in
use. As (in my opinion) does Ada.

> 
> -- Georg

art



  reply	other threads:[~2004-10-07 18:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-01 19:34 Ada Pointer Problem aschwarz1309
2004-10-02  0:47 ` Jeffrey Carter
2004-10-02 23:37   ` Randy Brukardt
2004-10-06 15:43     ` skidmarks
2004-10-06 18:19       ` Jeffrey Carter
2004-10-16  3:53         ` Benjamin Ketcham
2004-10-16 13:25           ` John B. Matthews
2004-10-18 18:09           ` Georg Bauhaus
2004-10-06 19:29       ` Georg Bauhaus
2004-10-07 18:45         ` skidmarks [this message]
2004-10-08  0:35           ` Jeffrey Carter
2004-10-08 12:02           ` Jean-Pierre Rosen
2004-10-08 16:58             ` Ludovic Brenta
2004-10-08 23:26             ` Björn Persson
2004-10-10 18:01             ` skidmarks
2004-10-08 14:03           ` Georg Bauhaus
2004-10-08 14:23           ` Dale Stanbrough
  -- strict thread matches above, loose matches on Subject: below --
2004-10-01 15:26 skidmarks
2004-10-01 15:50 ` David C. Hoos
2004-10-01 18:15   ` Jeffrey Carter
2004-10-01 17:24 ` Ludovic Brenta
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox