comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam@spam.com>
Subject: Re: pointer questions
Date: Thu, 27 Oct 2005 18:43:26 GMT
Date: 2005-10-27T18:43:26+00:00	[thread overview]
Message-ID: <id98f.2656$yX2.2217@newsread2.news.pas.earthlink.net> (raw)
In-Reply-To: <wccvezjrqvv.fsf@shell01.TheWorld.com>

Robert A Duff wrote:
> 
> Never?  Well, these kinds of low-level hacks are _rarely_ a good idea.
> But you might need them when interfacing to some other language
> that uses such trickery.

True, but then you're not using Ada, you're using Ada and X, which I addressed 
later. For just Ada, you never need the kind of pointers the OP was asking about.

> Maybe the kinds of programs I write are different.  Question for those
> who rarely use access types: what sort of application areas are you
> talking about?  Mine are usually software development tools -- such as
> compilers.

Maybe. I use unbounded data structures frequently, but I don't write a new one 
every time. Instead, I reuse existing generic data structures, so the code I 
write doesn't contain those access types. When you talk about all the access 
types in your compiler code, are you talking about frequent creation of new 
access types, reuse of existing but exposed access types, or reuse of packages 
that hide the use of access types? That will help decide if compilers are different.

For learning Ada, one should write some dynamic data structures, but to use Ada, 
you should reuse existing dynamic data structures. I don't count access types 
hidden in reused packages as using access types.

Recently, I've written a generic package for genetic algorithms, and a TSP 
program that uses it, and a package to implement the Nicias encryption 
algorithm, and a program that uses it. Nary an access type in sight.

> If I designed a language, I would go even further in that direction.
> I would allow mutually recursive types without intervening pointers.
> The only need for pointers in my language would be where
> reference semantics is desired -- e.g. when you want two pointers
> to the same object, such that updates to that object can be seen
> through both.

We're still waiting to see an informal specification for Duff, or whatever it's 
called :)

> I don't really agree.  A beginner to Ada who knows how to program
> (in some other language, such as C) might well want to make a
> linked list, for example, and that requires pointers of some
> sort -- usually access types.

Again, for learning Ada, certainly. For using Ada, no. Part of learning Ada is 
learning to reuse. Even after the beginner has crafted a generic, unbounded list 
to learn about generics, access types, memory management, and information 
hiding, it's still a good idea for him to use the unbounded list component from 
<your favorite library here> (or Ada.Containers in 0X) to learn to reuse others' 
packages, and to gain the benefit of SW that has been much more thoroughly 
tested than his own effort.

My comments that pointers are rarely needed in Ada are usually addressed to 
beginners coming from C who think they must use pointers for everything, from 
passing a parameter that can be modified to creating an array with bounds known 
only at run time. I hope that my saying this will cause them to stop, every time 
they think they need a pointer, and see if perhaps Ada can do it without one. In 
that way, perhaps they will gain a better understanding and appreciation of Ada.

-- 
Jeff Carter
"My mind is aglow with whirling, transient nodes of
thought, careening through a cosmic vapor of invention."
Blazing Saddles
85



  parent reply	other threads:[~2005-10-27 18:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-26 23:01 pointer questions Szymon Guz
2005-10-26 23:51 ` Gene
2005-10-26 23:58 ` tmoran
2005-10-27  1:12 ` Stephen Leake
2005-10-27  2:30 ` Steve
2005-10-27  5:56 ` Jeffrey R. Carter
2005-10-27 10:19   ` Szymon Guz
2005-10-27 14:14     ` Robert A Duff
2005-11-07  4:21       ` Dave Thompson
2005-10-27 14:11   ` Robert A Duff
2005-10-27 15:13     ` Marc A. Criley
2005-10-27 18:53       ` Jeffrey R. Carter
2005-10-27 17:29     ` Martin Dowie
2005-10-27 18:28       ` Marc A. Criley
2005-10-27 19:28         ` Martin Dowie
2005-10-28  0:12           ` Robert A Duff
2005-10-28 11:57           ` Dr. Adrian Wrigley
2005-10-28 21:26             ` Jeffrey R. Carter
2005-10-30 22:26               ` Robert A Duff
2005-10-31  6:21                 ` Jeffrey R. Carter
2005-11-02  0:52                   ` Dr. Adrian Wrigley
2005-11-02  3:46                     ` Jeffrey R. Carter
2005-11-02 11:16                       ` Dr. Adrian Wrigley
2005-11-02 13:39                     ` Robert A Duff
2005-11-02 15:34                     ` Bob Spooner
2005-11-02 18:59                     ` Björn Persson
2005-10-27 18:43     ` Jeffrey R. Carter [this message]
2005-10-28  0:42       ` Robert A Duff
2005-10-28  5:58         ` Martin Dowie
2005-10-28 21:24         ` Jeffrey R. Carter
2005-10-28 11:53     ` David
2005-10-29 12:25       ` Simon Wright
2005-10-27 17:19 ` Martin Krischik
2005-11-07  4:21   ` Dave Thompson
replies disabled

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