From: Anonymous Coward on
In article <ulkzmsw5v.fsf(a)acm.org>, Stephen Leake wrote:
>
> You introduced a name collision by the 'use' clause; that can always
> cause name collisions. The proper solution in that case is to use
> the qualified name.

I agree. I personally take it an extreme step further, and never use
use clauses anywhere. They shouldn't even be in the language. Every
Ada project I've worked on that had a coding standard banned the use
clause, and rightly so.

I don't only oppose it because of the ambiguity, but even when there
is no ambiguity, it's a severe inconvenience to have to grep a large
tree to hunt down a declaration. Then to possibly get multiple hits
and have to compare two lists of packages to discover which hit is the
correct one. By the time you make it to the declaration you're
looking for, you've forgotten why you need to look at it :)

Clearly the typing time saved by the use clause cannot possibly offset
the time lost on all the resulting code searches.
From: Ed Falis on
On Sat, 19 Nov 2005 15:28:25 -0500, Anonymous Coward <spam(a)spam.com> wrote:

> I don't only oppose it because of the ambiguity, but even when there
> is no ambiguity, it's a severe inconvenience to have to grep a large
> tree to hunt down a declaration. Then to possibly get multiple hits
> and have to compare two lists of packages to discover which hit is the
> correct one. By the time you make it to the declaration you're
> looking for, you've forgotten why you need to look at it

If you were using a modern editor, with Ada cross-referencing, you
wouldn't have this problem. GPS, emacs Ada mode, ObjectAda and quite a
few others provide this.

- Ed
From: Dmitry A. Kazakov on
On Sat, 19 Nov 2005 20:28:25 GMT, Anonymous Coward wrote:

> In article <ulkzmsw5v.fsf(a)acm.org>, Stephen Leake wrote:
>>
>> You introduced a name collision by the 'use' clause; that can always
>> cause name collisions. The proper solution in that case is to use
>> the qualified name.
>
> I agree. I personally take it an extreme step further, and never use
> use clauses anywhere. They shouldn't even be in the language. Every
> Ada project I've worked on that had a coding standard banned the use
> clause, and rightly so.

No, name collisions better be prevented by making "use" illegal when it
hides anything.

BTW, what about banning implicit "use" of "Standard"? Care to write an AI
to make Integer, "+", "-" etc invisible? (:-))

> I don't only oppose it because of the ambiguity, but even when there
> is no ambiguity, it's a severe inconvenience to have to grep a large
> tree to hunt down a declaration.

IDE should have "go to declaration" button.

> Then to possibly get multiple hits
> and have to compare two lists of packages to discover which hit is the
> correct one. By the time you make it to the declaration you're
> looking for, you've forgotten why you need to look at it :)

It is no matter "where", "what" does matter. If you need to frequently
browse sources to determine "what", then the program is poorly designed.

> Clearly the typing time saved by the use clause cannot possibly offset
> the time lost on all the resulting code searches.

What about the time spent on reading something like A.B.C.D.E.F.G.H?

If I were a "use"-hater I would propose a reverse notation for fully
qualified names: H of G of F of E of D of C of B of A (at least for those
who reads programs from left to right it would be a great help! (:-))

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Simon Wright on
"Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:

> What about the time spent on reading something like A.B.C.D.E.F.G.H?

As used in the GNAT sources, for example ..

package SSE renames System.Storage_Elements;

within a reasonably short local scope (a page or two, perhaps).
From: Anonymous Coward on
In article <1ef4kvy6kdkwz.oqmb8acj5joo.dlg(a)40tude.net>,
Dmitry A. Kazakov wrote:
>
> No, name collisions better be prevented by making "use" illegal when
> it hides anything.

The use clause is barred by coding standards for a good reason, and I
don't think it's necessarily name collisions that drive this rule.
Programmers are forced to resolve name collisions, with or without the
USE clause. The use clause is banned because it makes code unreadable
and difficult to use. As Joel Spolsky said, travel should be minimal
when interpretting a line of code. Fully qualified naming is a better
style because you know immediately, from the code itself, where the
identifier lives. And if you need to see the declaration, you know
immediately where to go.

> BTW, what about banning implicit "use" of "Standard"? Care to write
> an AI to make Integer, "+", "-" etc invisible? (:-))

The "use type" clause is a different beast, and I do not object to its
use; nor is it banned in any coding standard I've read.

> IDE should have "go to declaration" button.

I agree, but not all IDEs have that luxery. The last IDE I worked in
had the option, but it was broken. My current environment is emacs,
which doesn't offer that feature by itself. I've only seen it when
emacs is paired with Apex. Even under the best tools, where a
mouseover might reveal the home for some declaration, it's still poor
style to not have that information in the text, so the reader doesn't
have to mouse around compulsively, as the keyboard is faster than the
mouse.

>> Then to possibly get multiple hits and have to compare two lists of
>> packages to discover which hit is the correct one. By the time you
>> make it to the declaration you're looking for, you've forgotten why
>> you need to look at it :)
>
> It is no matter "where", "what" does matter. If you need to
> frequently browse sources to determine "what", then the program is
> poorly designed.

Certainly not. I would say just the opposit. If you're repeating
information from your declaration in your identifiers, then you've
created a maintenance problem by introducing too much noise, also
forcing identifiers to change whenever the declaration changes. A
good design doesn't repeat this information.

>> Clearly the typing time saved by the use clause cannot possibly offset
>> the time lost on all the resulting code searches.
>
> What about the time spent on reading something like A.B.C.D.E.F.G.H?

If you have something like that, then there's something wrong with the
architecture of your project. A user should not need visibility into
such a deep level within an external component.
 |  Next  |  Last
Pages: 1 2 3 4
Prev: Debugger for GNAT
Next: Help installing GCC/GNAT 4.0.2