From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Don't use the "use" clause
Date: Fri, 27 Jan 2006 16:23:58 +0100
Date: 2006-01-27T16:23:58+01:00 [thread overview]
Message-ID: <kzwbjdb0auzq.1kah1latt0mb1.dlg@40tude.net> (raw)
In-Reply-To: W6idnXsgTv8f7UTenZ2dnUVZ_tGdnZ2d@megapath.net
On Thu, 26 Jan 2006 19:04:38 -0600, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:92132rehnlw6$.127gl4b6mfbnx.dlg@40tude.net...
>> On Wed, 25 Jan 2006 15:46:06 -0600, Randy Brukardt wrote:
> ...
>> Anyway, differentiating between direct and indirect visibility introduces
>> aliasing, which is not a good thing. OK, you might say that eluding "use"
>> would prevent aliasing, but then that argument would hit child and nested
>> packages as well.
>
> It does. I think all packages should have the same sort of indirect
> visibility; I'd ban nested ones, and child ones would work the same as other
> library units. But that's not Ada.
OK, without generics it might work.
>>> You want to get rid of selected notation?
>
>>Ideally "." should be an operation as any other, to override and to
>>overload.
>
> There has to be some basement in the syntax of operations/operators that
> never change.
It should be up to the programmer. The language should not prescribe the
meaning of "*" or ".". However it can forbid overriding "." for certain
things, like packages.
> Otherwise, you end up with a write-only language. The
> visibility use of "." is one of those (obviously, you could use a different
> symbol than ".", but I think you need something whose meaning doesn't change
> for this purpose). Dereferencing is another matter, and it's unfortunate
> that Ada mixes the two up -- they're completely unrelated. Pascal's "^"
> operator would be better (and I agree that that should be overridable).
Well, I don't think that there should be such operator at all. Reference
types should inherit parent's operations, which in effect would mean their
full transparency. If ":=" should mean reference copy, then the reference
type have to override it.
>>> So that there is no way to figure
>>> out where rarely used things are declared? An occurrence of "Blocked_Sum" in
>>> a program can be totally mysterious, while Message_Statistics.Blocked_Sum is
>>> much clearer.
>>
>> Why is it cleaner? It could only be if Message_Statistics were better known
>> than Blocked_Sum. That is a result of design, not a function of nesting or
>> other hierarchy.
>
> Packages are the root of all organization in Ada; it's only the packages
> that you have to know instantly to understand an Ada program with few use
> clauses. Having to know all of the entities in a program well to understand
> it is going to be information overload.
Packages have no properties of their own. Programs are written in terms of
types, objects, operations.
>> Example: I know well that "*" can multiply string by
>> number, but I cannot say where it is declared without searching through
>> ARM.
>
> "*" is a terrible name for a string operation, and (while I know it's there)
> it's not one that I'd ever think of. (It's certainly not a native operation
> of strings, and thus shouldn't be named with an operator. "*" is only for
> numbers and numerical abstractions.) In any case, I would write it as
> Ada.Strings.Unbounded."*" -- and then I'd know instantly that it is a string
> operation, and know where to look if I need to know more.
But it is not a string operation. It is a string-valued operation defined
on strings and numbers. Ada.Strings.Unbounded."*" is misleading. It could
be in Ada.Numeric or in Ada.Container. Actually, it is a reincarnation of
Hungarian notation for subroutines - an evil thing. Names should reflect
semantics, rather than types.
> I think you'd have a better argument if the routine was called
> "Replicate_String".
Take Is_Letter.
> But that was a previous point (I forget who said it) --
> the name of this operation should just be "Replicate", and the package name
> or object name will tell you want is getting "Replicated". (That's the
> naming we used in Claw, for instance, very short names for only the
> operation, where either the object name or the package name tell you what
> the type is. If you use use clauses and call all of your windows W, your
> Claw program will be indecipherable. Tough, use better names.)
This is a no-use-friendly naming convention, especially useful for
generics. But that does not mean that there cannot be a use-friendly
alternative.
> Note that the prefixed call notation (introduced in Ada 2005) reduces the
> need for use clauses and traditional selected notation by using the object
> name instead.
Firstly, I think that introduction of prefixed notation probably was a
mistake. We'd better have removed it for tasks and protected objects.
Secondly, prefix notation as introduced in Ada 2005 is an equivalent of use
clause! In C++ both "use-" and "with-like-prefix" notations coexist. For
example:
X.A::B::C::D::Foo (); // "with-like-prefix"
X.Foo (); // "use-like-prefix"
Ada's equivalent of the first could be:
X.Standard.A.B.C.D.Foo; -- Let's enjoy fully qualified names!
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2006-01-27 15:23 UTC|newest]
Thread overview: 112+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-15 16:03 Request for comments on simple Ada program Maciej Sobczak
2005-11-15 17:43 ` Samuel Tardieu
2005-11-15 17:47 ` Samuel Tardieu
2005-11-15 21:28 ` Jacob Sparre Andersen
2005-11-15 21:53 ` Samuel Tardieu
2005-11-16 9:10 ` Anders Wirzenius
2005-11-15 21:55 ` Samuel Tardieu
2005-11-16 9:03 ` Niklas Holsti
2005-11-16 14:21 ` Jacob Sparre Andersen
2005-11-16 17:08 ` Niklas Holsti
2005-11-16 7:11 ` Brian May
2005-11-15 18:29 ` jimmaureenrogers
2005-11-15 19:33 ` tmoran
2005-11-16 14:46 ` jimmaureenrogers
2005-11-16 18:05 ` Martin Dowie
2005-11-16 19:54 ` tmoran
2005-11-15 18:52 ` Martin Krischik
2005-11-15 19:33 ` tmoran
2005-11-16 3:10 ` Ada Quality and Style book discussion Anonymous Coward
2005-11-16 4:09 ` tmoran
2005-11-16 5:49 ` Simon Wright
2005-11-16 7:03 ` Martin Dowie
2005-11-17 4:49 ` Anonymous Coward
2005-11-17 6:48 ` Martin Dowie
2005-11-17 11:45 ` Georg Bauhaus
2005-11-17 12:37 ` Stephen Leake
2005-11-17 13:24 ` Georg Bauhaus
2005-11-17 23:15 ` Stephen Leake
2005-11-19 20:28 ` Don't use the "use" clause Anonymous Coward
2005-11-19 20:35 ` Ed Falis
2005-11-21 17:36 ` David Emery
2005-11-21 19:20 ` Ed Falis
2005-11-21 22:21 ` David Trudgett
2005-11-21 22:51 ` Ed Falis
2005-11-22 0:15 ` Anonymous Coward
2005-11-23 4:09 ` Ed Falis
2005-11-23 19:26 ` tmoran
2005-11-19 21:48 ` Dmitry A. Kazakov
2005-11-19 22:33 ` Simon Wright
2005-11-19 23:40 ` Anonymous Coward
2005-11-20 11:07 ` Dmitry A. Kazakov
2005-11-20 19:50 ` Jeffrey R. Carter
2005-11-20 2:53 ` Stephen Leake
2005-11-20 3:57 ` Anonymous Coward
2005-11-20 10:44 ` Pascal Obry
2005-11-20 19:48 ` Jeffrey R. Carter
2005-11-22 5:11 ` greptree lou
2005-11-22 6:08 ` greptree Simon Wright
2005-11-25 1:00 ` greptree Björn Persson
2006-01-23 12:51 ` Don't use the "use" clause adaworks
2006-01-23 20:21 ` Jeffrey R. Carter
2006-01-24 2:27 ` Stephen Leake
2006-01-24 3:32 ` Ed Falis
2006-01-24 4:44 ` Jeffrey R. Carter
2006-01-24 22:53 ` Stephen Leake
2006-01-24 8:54 ` Dmitry A. Kazakov
2006-01-24 9:48 ` Martin Dowie
2006-01-24 10:28 ` Dmitry A. Kazakov
2006-01-24 13:30 ` brian.b.mcguinness
2006-01-24 20:03 ` Simon Wright
2006-01-24 23:00 ` Stephen Leake
2006-01-25 4:58 ` Jeffrey R. Carter
2006-01-24 23:38 ` Randy Brukardt
2006-01-25 14:49 ` Dmitry A. Kazakov
2006-01-25 21:46 ` Randy Brukardt
2006-01-26 9:14 ` Dmitry A. Kazakov
2006-01-27 1:04 ` Randy Brukardt
2006-01-27 15:23 ` Dmitry A. Kazakov [this message]
2006-01-27 16:35 ` Georg Bauhaus
2006-01-27 23:09 ` Randy Brukardt
2006-01-27 23:18 ` Randy Brukardt
2006-01-28 10:41 ` Dmitry A. Kazakov
2006-01-24 22:55 ` Stephen Leake
2006-01-24 9:42 ` Martin Dowie
2006-01-24 23:02 ` Stephen Leake
2006-01-25 9:14 ` Martin Dowie
2006-01-25 11:01 ` Peter Amey
2006-01-25 11:06 ` Martin Dowie
2006-01-25 20:07 ` Jeffrey R. Carter
2006-01-31 2:24 ` Stephen Leake
2006-02-09 5:13 ` Anonymous Coward
2005-11-17 20:55 ` Ada Quality and Style book discussion Simon Wright
2005-11-18 0:44 ` Larry Kilgallen
2005-11-19 20:56 ` Anonymous Coward
2005-11-19 22:41 ` Simon Wright
2005-11-20 0:03 ` Anonymous Coward
2005-11-17 4:23 ` Ada Quality and Style book discussion ("_Type" suffix) Anonymous Coward
2005-11-17 10:51 ` Martin Dowie
2005-11-19 21:52 ` Anonymous Coward
2005-11-20 15:50 ` Martin Dowie
2005-11-17 11:34 ` Georg Bauhaus
2005-11-17 11:53 ` Martin Dowie
2005-11-17 13:26 ` Georg Bauhaus
2005-11-17 12:26 ` Brian May
2005-11-17 13:45 ` Martin Dowie
2005-11-17 14:22 ` Marc A. Criley
2005-11-17 14:50 ` Martin Dowie
2005-11-18 3:04 ` Brian May
2005-11-18 9:23 ` Maciej Sobczak
2005-11-18 14:00 ` Marc A. Criley
2005-11-18 11:48 ` Java exception model. Was: " Peter C. Chapin
2005-11-18 13:18 ` Dmitry A. Kazakov
2005-11-19 18:06 ` Peter C. Chapin
2005-11-19 18:58 ` Dmitry A. Kazakov
2005-11-21 22:38 ` Brian May
2005-11-21 23:27 ` Brian May
2005-11-18 22:33 ` Simon Wright
2005-11-17 14:03 ` Hyman Rosen
2005-11-20 19:41 ` Jeffrey R. Carter
2005-11-20 20:43 ` Dmitry A. Kazakov
2005-11-21 0:00 ` Simon Wright
2005-11-16 13:51 ` Ada Quality and Style book discussion Marc A. Criley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox