comp.lang.ada
 help / color / mirror / Atom feed
From: Richard D Riehle <laoXhai@ix.netcom.com>
Subject: Re: Where is the elusive jump command?
Date: 2000/03/30
Date: 2000-03-30T19:00:38+00:00	[thread overview]
Message-ID: <8c088m$puh$1@slb6.atl.mindspring.net> (raw)
In-Reply-To: 8brrpj$i04$1@nnrp1.deja.com

In article <8brrpj$i04$1@nnrp1.deja.com>,
	Robert Dewar <robert_dewar@my-deja.com> wrote:

>In article <8brn4k$p6i$1@slb0.atl.mindspring.net>,
>  Richard D Riehle <laoXhai@ix.netcom.com> wrote:
>>
>> To write such a compiler, it is necessary to include certain
>> reserved words and syntactic constructs that "tip off" the
>> compiler to possible problems.  The word _aliased_ seems to me
>> to be one of those "tip-off the compiler" words.  This can
>> later be augmented with a more technical explanation, but it
>> works well for most early students when explained  within the
>> framework of the above stated goals.
>
>I find this a very odd view of the ALIASED keyword. The reason
>for this has nothing to do with the compiler. As in the case
>of most C compilers, the compiler could look at your code to
>see whether or not you take the address of something. That's
>not at all the intention.

This could have been accomplished without the word _aliased_
keyword.  Could it have been as easily checked by the compiler?
It seems to me that _aliased_ helps prevent the very kind of
errors one encounters in C.   If the reserved word is not intended
to provide special information to the compiler, why not just do
this the same way we do it in C?   The fact is that I cannot use
'Access on a value that is not aliased.   The compiler prevents it.
Hence, I see this is as a signal to the compiler that I am trying
to do something illegal.  It is also a tip-off to the compiler that
accessibility rules need to be enforced.  

Whatever the original intent of _aliased_ , it has the effect of 
letting the programmer know about the legality or illegality of a
syntactic construct, ensuring that certain practices are avoided,
and making it clear what one's intentions are in the source code.

>The point is that aliasing is generally speaking very bad
>practice. The facility for pointing to variables was introduced
>in Ada 95 with reluctance when certain convincing examples
>were given, including in particular the construction of
>static structures involving pointers.

I am one of those people who understands the reluctance to introduce
this construct into Ada.  It turns out to be a valuable feature of
the language and the accessibility rules do make it a little bit
safer than the corresponding code in C.   Of course, Unchecked_Access
does allow unruly behavior from some programmers.  

>It should be VERY sparingly used, really it should be regarded
>like Unchecked_Conversion, a noisy declaration that you intend
>to do something rather undesirable, namely in this case the
>creation of possibly confusing aliases for the variable.

Lots of things should be sparingly used.  One might say the same
about tagged types and inheritance.  Certainly most agree that
_goto_ should be sparingly used.  Indeed, you wrote a thoughtful
contribution last year asserting that assignment should be sparingly 
used.  Perhaps requiring the reserved word _aliased_ encourages the
sparing use of it in source code.

There are situations, particulary interfacing with some of the operating
system facilities, where a general access type, and the word _aliased_
makes good sense.  Also, many of the programmers I deal with in my
daily work are former C/C++ programmers who are accustomed to working
without a safety-net.  For them, the accessibility rules associated
with _aliased_ values, make sense, even though they are sometimes a
bit annoying.  

>Note by the way that 'Address can be applied freely to variables
>in any case without the ALIASED keyword, so Ada 95 compilers in
>any case have to have the circuitry for automatic detection of
>which variables have their addresses taken and which do not
>(GNAT most certainly has this circuit). Thus ALIASED is not of
>the slightest utility to the compiler (in GNAT it is essentially
>ignored except for providing the essential semantic checking
>associated with this facility).

OK.  Semantic checking seems somewhat important.  The compiler
does check this.  Why bother with it?  It seems to me that this is
because there are some associated rules, and these are checked at
compile time.  To my mind, this illustrates one of the most important
aspects of Ada:  
     maximizing detection of programmer stupidity at compile time.

Perhaps _aliased_ is of no importance to the compiler from the 
point-of-view of creating an operational compiler.  That would be
true, I suspect, of many other Ada features.  Donald Knuth is fond
of reminding us that we are not writing programs for compilers but
for ourselves and other people.  We make mistakes.  Well, I do anyway,
lots of them, it would seem.  The Ada language helps us minimize 
those mistakes by enabling a compiler technology that notices those
mistakes.  The keyword, _aliased_ , may be of no intrinsic value to
the compiler, but it does "tip off" the compiler to the reality that
we may have made some silly error in our coding.  When the compiler
informs of us of this fact, we have the option of correcting our
code.  Is this a superfluous notification?   I don't think so.

As to 'Address, this is really fraught with potential dangers.  Now 
there is a language construct that needs to be used sparingly.  

Richard Riehle





  reply	other threads:[~2000-03-30  0:00 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-21  0:00 Where is the elusive jump command? dis90072
2000-03-21  0:00 ` Stanley R. Allen
2000-03-21  0:00 ` Nicolas Brunot
2000-03-21  0:00 ` Nicolas Brunot
2000-03-27  0:00 ` Robert A Duff
2000-03-28  0:00   ` Ken Garlington
2000-03-28  0:00     ` Robert Dewar
2000-03-28  0:00       ` Ken Garlington
2000-03-28  0:00         ` Marin D. Condic
2000-03-28  0:00           ` Robert Dewar
2000-03-29  0:00             ` Marin D. Condic
2000-03-29  0:00               ` Gary Scott
2000-03-29  0:00                 ` Robert Dewar
2000-03-30  0:00                   ` Gautier
2000-03-30  0:00                     ` Gary Scott
2000-03-30  0:00                       ` Gautier
2000-03-30  0:00                       ` David Starner
2000-03-30  0:00                         ` William B. Clodius
2000-03-30  0:00                   ` David Starner
2000-03-30  0:00                     ` Marin D. Condic
2000-03-30  0:00                       ` Gary Scott
2000-03-31  0:00                         ` Tarjei T. Jensen
2000-03-31  0:00                           ` Larry Kilgallen
2000-03-31  0:00                             ` Gary Scott
2000-03-30  0:00                       ` Samuel T. Harris
2000-03-30  0:00                       ` Dan Nagle
2000-03-30  0:00                         ` David Starner
2000-03-30  0:00                         ` Samuel T. Harris
2000-03-31  0:00                           ` Gisle S�lensminde
2000-03-30  0:00                       ` Larry Kilgallen
2000-03-31  0:00                       ` Tarjei T. Jensen
2000-04-12  0:00                         ` Robert A Duff
2000-04-12  0:00                           ` Stanley R. Allen
2000-04-12  0:00                             ` Samuel T. Harris
2000-04-13  0:00                               ` Stanley R. Allen
2000-04-14  0:00                                 ` Samuel T. Harris
2000-04-14  0:00                                   ` BASIC->Ada, was " tmoran
2000-04-15  0:00                                 ` Robert Dewar
2000-04-15  0:00                             ` Robert Dewar
2000-04-13  0:00                           ` Tarjei T. Jensen
2000-03-31  0:00                       ` Gisle S�lensminde
2000-03-31  0:00                       ` Gautier
2000-03-30  0:00                   ` Gary Scott
2000-03-30  0:00               ` Alfred Hilscher
2000-03-29  0:00             ` Richard D Riehle
2000-03-29  0:00               ` Robert Dewar
2000-03-30  0:00                 ` Richard D Riehle [this message]
2000-04-01  0:00                   ` Robert A Duff
2000-04-02  0:00                     ` Robert Dewar
2000-04-02  0:00                     ` Richard D Riehle
2000-04-02  0:00                       ` Robert Dewar
2000-04-02  0:00                       ` Robert Dewar
2000-03-30  0:00                 ` Alfred Hilscher
2000-04-01  0:00                   ` Robert Dewar
2000-04-04  0:00                     ` Alfred Hilscher
2000-04-05  0:00                     ` Ole-Hjalmar Kristensen
2000-04-05  0:00                       ` Larry Kilgallen
2000-04-06  0:00                         ` Ole-Hjalmar Kristensen
2000-04-06  0:00                           ` OS Bindings (was: Where is the elusive jump command?) Larry Kilgallen
     [not found]                             ` <eisner comp.lang.ada:53670>
2000-04-06  0:00                               ` Larry Kilgallen
2000-04-06  0:00                                 ` Robert Dewar
2000-04-08  0:00                                   ` nickerson
2000-04-09  0:00                                     ` Robert Dewar
2000-04-06  0:00                             ` Robert Dewar
2000-04-07  0:00                               ` Tarjei T. Jensen
2000-04-09  0:00                                 ` Robert Dewar
2000-04-10  0:00                                   ` Tarjei T. Jensen
2000-04-12  0:00                                     ` Robert Dewar
2000-04-12  0:00                                       ` Robert A Duff
2000-04-12  0:00                                         ` Tarjei T. Jensen
2000-04-12  0:00                                           ` Robert Dewar
2000-04-12  0:00                                           ` Robert Dewar
2000-04-12  0:00                                           ` Robert A Duff
2000-04-12  0:00                                             ` Robert Dewar
2000-04-12  0:00                                               ` Robert A Duff
2000-04-15  0:00                                                 ` Robert Dewar
2000-04-15  0:00                                                 ` Robert Dewar
2000-04-15  0:00                                                   ` Gisle S�lensminde
2000-04-13  0:00                                               ` Tarjei T. Jensen
2000-04-13  0:00                                                 ` Gisle S�lensminde
2000-04-12  0:00                                             ` Florian Weimer
2000-04-13  0:00                                             ` Tarjei T. Jensen
2000-04-13  0:00                                               ` Robert A Duff
2000-04-18  0:00                                                 ` Tarjei T. Jensen
2000-04-15  0:00                                               ` Robert Dewar
2000-04-15  0:00                                                 ` Tarjei T. Jensen
2000-04-12  0:00                                       ` Tarjei T. Jensen
2000-04-12  0:00                                         ` Robert Dewar
2000-04-13  0:00                                           ` Tarjei T. Jensen
2000-04-15  0:00                                             ` Robert Dewar
2000-04-15  0:00                                               ` Tarjei T. Jensen
2000-04-06  0:00                             ` Ole-Hjalmar Kristensen
2000-03-28  0:00   ` Where is the elusive jump command? Dale Stanbrough
  -- strict thread matches above, loose matches on Subject: below --
2000-03-21  0:00 dis90072
2000-03-21  0:00 ` Preben Randhol
2000-03-30  0:00   ` Alfred Hilscher
replies disabled

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