comp.lang.ada
 help / color / mirror / Atom feed
From: Vinzent 'Gadget' Hoefler <nntp-2004-05@t-domaingrabbing.de>
Subject: Re: Manifesto against Vector
Date: Thu, 06 May 2004 15:30:42 +0200
Date: 2004-05-06T15:30:42+02:00	[thread overview]
Message-ID: <12dk90h0dif5h4phes8n9m9p7jo1u5gqc8@jellix.jlfencey.com> (raw)
In-Reply-To: 7v9k901htdtm86kg9umqhptirt7vmjcr3m@4ax.com

Dmitry A. Kazakov wrote:

>On Thu, 06 May 2004 11:41:11 +0200, Vinzent 'Gadget' Hoefler
><nntp-2004-05@t-domaingrabbing.de> wrote:
>
>>Dmitry A. Kazakov wrote:
>>
>>>Why that should be told? I'd say that "with" is superfluous.
>>
>>No! If at all then it is "use" which is superfluous. ;-)
>
>How so? "Use" has some semantical sense. It changes visibility. You
>might claim that this is not necessary, but that would be another
>story. On the contrary "with" has no other sense than being just a
>hint to the compiler/linker.

And a idea to me which packages another one is using. This is
especially useful with some of the more "evil" parts of Ada like
Unchecked_Conversion. :)

>It could well be just a pragma, like the
>elaboration control ones.

Yes. Or like the C pragmas that tells the Preprocessor which files it
should include to get all the prototype-declarations. Well, sometimes
it even works without these, yes. Do you really *want* it to work in a
similar way? I don't.

(BTW, for that discussion it might be funny to note that these days
even more and more of the C++-folks consider "using some_namespace;"
to be evil. And now we want to encourage to do exactly the opposite of
that in Ada?)

>>>Maybe, but it should be placed at the beginning of the context. So it
>>>is just one line difference. Not a big issue, IMO.
>>
>>It is more than a single line. Consider this:
>>
>>|with Interfaces;
>> ^^^^
>>|
>>|package body Timer is
>>|
>>[...]
>>|   function Hi_Byte (Value : in Interfaces.Unsigned_16)
>>|     return Interfaces.Unsigned_8 is
>>|      use type Interfaces.Unsigned_16;
>>       ^^^
>>|   begin
>>|      return Interfaces.Unsigned_8 (
>>|          Interfaces.Shift_Right (Value, 8) and 16#FF#);
>>|   end Hi_Byte;
>
>We have no "with type" clause, so this example is incorrect.

Well, then read "use Interfaces;" instead and imagine all the packages
prefixes would go away then.

For me it is still the same principle: Make something as local as you
can. No matter if it is a variable, a procedure, ... or a namespace.

>>>with Foo;
>>>procedure P (<something here needs visibility of Foo>);
>>
>>Simple: Use the full name there. If it's too long for you, I'd say
>>rename it.
>
>It cannot be. P is a unit! (:-))

Hmm, what the heck? I was under the impression that

|subtype Sys_Addr is System.Address;
|
|procedure (foo : Sys_Addr)

would work.

>Then semantics of renaming is inconsitent with one of "use", or better
>to say, simply inconsistent. This is the source of numerous problems:
>
>with Ada.IO_Exceptions;
>package A is
>   End_Error : exception renames Ada.IO_Exceptions.End_Error;
>   X_Error : exception;
>end A;
>--------
>with A;
>package B renames A;
>--------
>with A; use A;
>with B; use B;
>with Ada.IO_Exceptions; use Ada.IO_Exceptions;
>procedure C is
>begin
>   ...
>exception
>   when X_Error =>
>      -- This is OK, multiple views of same thing
>      ...
>   when End_Error =>
>      -- This is illegal, viewing two different views of one thing!
>      ...
>end C;

See. That's a perfect example for a "use"-Problem, which I simply want
to avoid (and which I want to do consistently):

|c.adb:12:09: "End_Error" is not visible
|c.adb:12:09: multiple use clauses cause hiding
                       ^^^^^^^^^^^
|c.adb:12:09: hidden declaration at a.ads:3
|c.adb:12:09: hidden declaration at a-ioexce.ads:26
|gnatmake: "c.adb" compilation error

when you specify:

|   when A.End_Error =>

instead it surprisingly works. And if you always do that, there is
even no inconsistency that you sometimes use the short name and
sometimes the fully specified name "randomly" all over a package, just
depending on which packages you've just had to use and where the
compiler complained about not wanting to know what to do.

I don't know what this has to do with renaming. If you'd declare
End_Error separately in the packages you would run into the same
problem, so in fact it is a "use" problem.

Well, you might argue, just because you renamed it and thus in fact is
exactly the same, the compiler could figure this out by itself. But if
it would really do that, it then would be me to call this behaviour
inconsistent.

>>It's much more simple: Never use "use". :)
>
>Once I will become a rich man, I will buy a LCD with horizontal
>resolution of 10240 pixels, install small fonts, get spectacles ...
>(:-))

Considering I don't use "use" globally[0] and even restrict myself to
72 columns, I don't really understand that part of the problem. :)


Vinzent.

[0] And even locally I use "use" in relatively seldom circumstances,
the above "use type" is just because I consider the line
  | return Interfaces.Unsigned_8 (
  |   Interfaces."and" (Interfaces.Shift_Right (Value, 8), 16#FF#));
a little bit to much overkill even for my attitude to not using "use"
as much as I can't. Especially because this whole messy line just
compiles to a single "shrw $8, %ax". :)



  reply	other threads:[~2004-05-06 13:30 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-04  3:20 Manifesto against Vector Alexander E. Kopilovich
2004-05-04 16:30 ` chris
2004-05-04 17:19   ` Marius Amado Alves
2004-05-04 20:40     ` Peter C. Chapin
2004-05-04 20:58       ` Xenos
2004-05-07  8:05         ` Ranges in C++ Martin Krischik
2004-05-07 23:18           ` James Rogers
2004-05-08  6:45             ` Martin Krischik
2004-05-10 16:19             ` Xenos
2004-05-10 18:04               ` Martin Krischik
2004-05-10 19:03                 ` Xenos
2004-05-11  5:59                   ` Martin Krischik
2004-05-04 17:16 ` Manifesto against Vector Jeffrey Carter
2004-05-04 18:24   ` Marius Amado Alves
2004-05-04 19:17     ` Xenos
2004-05-04 19:53       ` Marius Amado Alves
2004-05-05  9:24       ` Georg Bauhaus
2004-05-05  5:28     ` Russ
2004-05-05  7:01       ` tmoran
2004-05-05 17:37       ` Martin Dowie
2004-05-06  3:42         ` Russ
2004-05-06  5:55           ` Martin Dowie
2004-05-06  7:03           ` Jean-Pierre Rosen
2004-05-06  9:29             ` Dmitry A. Kazakov
2004-05-06  9:41               ` Vinzent 'Gadget' Hoefler
2004-05-06 12:44                 ` Dmitry A. Kazakov
2004-05-06 13:30                   ` Vinzent 'Gadget' Hoefler [this message]
2004-05-06 14:35                     ` Wes Groleau
2004-05-07  8:23                     ` Dmitry A. Kazakov
2004-05-07 12:38                       ` Vinzent 'Gadget' Hoefler
2004-05-09 20:34                         ` Dmitry A. Kazakov
2004-05-10  8:26                           ` Vinzent 'Gadget' Hoefler
2004-05-10 12:13                             ` Dmitry A. Kazakov
2004-05-06 14:48                   ` Georg Bauhaus
2004-05-07  8:31                     ` Dmitry A. Kazakov
2004-05-07 14:30                       ` Georg Bauhaus
2004-05-09 20:33                         ` Dmitry A. Kazakov
2004-05-12 19:49                       ` Randy Brukardt
2004-05-07  7:01                   ` Martin Krischik
2004-05-06  9:55               ` with and use again (was: Manifesto against Vector) Marius Amado Alves
2004-05-06 12:04                 ` Dmitry A. Kazakov
2004-05-07  6:53                   ` Martin Krischik
2004-05-09 20:33                     ` Dmitry A. Kazakov
2004-05-10  7:00                       ` Martin Krischik
2004-05-10 12:15                         ` Dmitry A. Kazakov
2004-05-07 16:27                 ` with and use again Warren W. Gay VE3WWG
2004-05-06 19:53               ` Manifesto against Vector Jean-Pierre Rosen
2004-05-07  0:42                 ` Jeffrey Carter
2004-05-07  6:49                   ` Jean-Pierre Rosen
2004-05-07 18:20                     ` Jeffrey Carter
2004-05-07 19:15                       ` Simon Wright
2004-05-10  6:49                       ` Jean-Pierre Rosen
2004-05-10 17:25                         ` Jeffrey Carter
2004-05-11 13:25                           ` Jean-Pierre Rosen
2004-05-07  5:00               ` Simon Wright
2004-05-07  6:40               ` Martin Krischik
2004-05-07 16:25               ` Warren W. Gay VE3WWG
2004-05-07  6:33             ` Martin Krischik
2004-05-06 14:28           ` Wes Groleau
2004-05-07  5:15             ` Russ
2004-05-10 11:55               ` Martin Dowie
2004-05-12 19:44                 ` Randy Brukardt
2004-05-12 19:42               ` Randy Brukardt
2004-05-13  5:23                 ` Russ
2004-05-13  5:48                   ` Randy Brukardt
2004-05-13 14:43                     ` Robert I. Eachus
2004-05-14  1:02                     ` Russ
2004-05-07  6:29           ` with use - again [Was: Manifesto against Vector] Martin Krischik
2004-05-07 11:18             ` Manuel Collado
2004-05-07 14:37               ` Georg Bauhaus
2004-05-07 13:41             ` Mark Lorenzen
2004-05-07 13:06               ` Martin Krischik
2004-05-05 19:45       ` Manifesto against Vector Marius Amado Alves
2004-05-04 18:42   ` Ada.Containers names Marius Amado Alves
2004-05-05 23:21   ` Manifesto against Vector Robert I. Eachus
2004-05-07  4:55 ` Matthew Heaney
2004-05-10  4:10   ` Matthew Heaney
2004-05-12  7:41     ` Pascal Obry
2004-05-12 12:11       ` Matthew Heaney
2004-05-12 12:50       ` Matthew Heaney
2004-05-10  6:41 ` Martin Krischik
2004-05-10 17:41   ` Jeffrey Carter
2004-05-11  1:29     ` Matthew Heaney
2004-05-11 20:53       ` Alexander E. Kopilovich
     [not found]       ` <XRVrJe0vzF@VB1162.spb.edu>
2004-05-11 22:26         ` Marius Amado Alves
2004-05-11  5:55     ` Martin Krischik
     [not found] <PnHmmb05QD@VB1162.spb.edu>
2004-05-04  9:07 ` Marius Amado Alves
2004-05-04 13:08   ` (see below)
2004-05-04 15:16     ` Martin Dowie
2004-05-05 13:21       ` Kevin Hostelley
2004-05-05 13:53         ` Georg Bauhaus
replies disabled

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