For me, a naming scheme that discourages the use of (package) use clauses is a bonus. (Such a scheme makes it easier to avoid use clauses.)
I personally
only use "use type" in new code (there's tons of old code for which that doesn't work, of course, but that doesn't change the principle).
In article <s5vqq9$lou$1@franka.jacob-sparre.dk>,
"Randy Brukardt" <randy@rrsoftware.com> wrote:
For me, a naming scheme that discourages the use of (package) use clauses
is
a bonus. (Such a scheme makes it easier to avoid use clauses.)
I agree to avoid use clauses.
(I personally prefer Lists.List, like Vincent Marciante -
i like Ada.Containers.* naming :-) )
I personally
only use "use type" in new code (there's tons of old code for which that
doesn't work, of course, but that doesn't change the principle).
what do you think about:
- "use all type" clauses?
- List.Clear? (could you remember me how you call that, please?)
- List.Clear does work only if List is tagged?
So, unless you are somehow OBLIGATED, use something,
anything, but ADA.
After fiddling around with ADA for awhile, I have concluded
that it's Just Not Worth It - too fiddly, TOO obsessed with
exact types and such. While there are SOME few justifications
for that, well, it's just pretty much UNUSABLE. If I need to
use an "old" language, well, FORTRAN is easier to deal with
and I actually *like* Pascal (I write lots of stuff in
Lazarus/FPC even today). And, of course, 'C' ...
So, unless you are somehow OBLIGATED, use something,
anything, but ADA.
Sorry, not what you wanted to hear, but ......
I will now de-subscribe.
"Thomas" <fantome.forums.tDeContes@free.fr.invalid> wrote in message news:62560a6b$0$18724$426a74cc@news.free.fr...
In article <s5vqq9$lou$1@franka.jacob-sparre.dk>,
"Randy Brukardt" <randy@rrsoftware.com> wrote:
I personally
only use "use type" in new code (there's tons of old code for which that >> doesn't work, of course, but that doesn't change the principle).
what do you think about:
- "use all type" clauses?
This is OK; I don't use them mainly because I only use features implemented in Janus/Ada, and "use all type" is not yet implemented there.
The fundamental problem with "use" is that it makes everything visible, and then deals with conflicts by making those things invisible again.
Since "use all type" only works on overloadable primitives (and things that work rather like primitives), it's fairly safe. One could make an argument that primitive operations should always be visible when the type is (that's not the Ada rule, but argubly it would work better in most circumstances) -- and you should always know to look at primitives anyway when trying to find something..
- List.Clear? (could you remember me how you call that, please?)
For tagged types, you can use prefix notation, so "My_List.Clear" is the easiest. With "use all type List", you can write Clear(My_List).
["Clear" works well even when someone uses
everything in sight] (of course, they may have a hard time finding where Clear is defined when debugging, but that's their choice).
- List.Clear does work only if List is tagged?
Right. There are a number of semantic issues for untagged types, the main ones having to do with implicit dereference (which occurs in this notation, as in any other selected_component notation). If you have a prefix of an access type, it gets very messy to determine which dereference is which. And just allowing composite types doesn't work well either: a private type that is completed with an access type would *lose* operations when it had full visibility -- that seems pretty weird.
It originally got limited to tagged types as that was easy to do and didn't have semantic issues.
We were going to look at generalizing the prefix
notation again (several people asked about it), but no one made a concrete proposal and it never went anywhere for Ada 2022.
In article <t357jt$v7n$1@dont-email.me>,
"Randy Brukardt" <randy@rrsoftware.com> wrote:
"Thomas" <fantome.forums.tDeContes@free.fr.invalid> wrote in message
news:62560a6b$0$18724$426a74cc@news.free.fr...
In article <s5vqq9$lou$1@franka.jacob-sparre.dk>,
"Randy Brukardt" <randy@rrsoftware.com> wrote:
I personally
only use "use type" in new code (there's tons of old code for which
that
doesn't work, of course, but that doesn't change the principle).
what do you think about:
- "use all type" clauses?
This is OK; I don't use them mainly because I only use features
implemented
in Janus/Ada, and "use all type" is not yet implemented there.
The fundamental problem with "use" is that it makes everything visible,
and
then deals with conflicts by making those things invisible again.
Since "use all type" only works on overloadable primitives (and things
that
work rather like primitives), it's fairly safe. One could make an
argument
that primitive operations should always be visible when the type is
(that's
not the Ada rule, but argubly it would work better in most
circumstances) --
and you should always know to look at primitives anyway when trying to
find
something..
are you speaking about a case like Ada.Text_IO.Unbounded_IO?
i would say that these subprograms are not primitives, since they are
not declared in the same package,
and i don't see in which case we could get a type visible but not its primitives.
in this case, the best thing to do that i found is:
use all type Ada.Text_IO.File_Type;
use Ada.Text_IO.Unbounded_IO;
is there sth best?
BTW, i often get a repetition in the same declare bloc, like:
File : Ada.Text_IO.File_Type;
use all type Ada.Text_IO.File_Type;
what do you think about generate an automatic "use all type" where the variable is declared?
- List.Clear? (could you remember me how you call that, please?)
For tagged types, you can use prefix notation, so "My_List.Clear" is the
easiest. With "use all type List", you can write Clear(My_List).
i asked for your opinion, because J-P. Rosen told me he doesn't like
that. so i would like to know main usages, practicals, ...
if i got it, you use prefix notation a lot, because you have no access
to "use all type"?
["Clear" works well even when someone uses
everything in sight] (of course, they may have a hard time finding where
Clear is defined when debugging, but that's their choice).
are you sure?
i would say either there is only 1 Clear for the type List, and if it's
a primitive it's easy to know where to find it, or there are many Clear
for the type List, and they are not visibles.
- List.Clear does work only if List is tagged?
Right. There are a number of semantic issues for untagged types, the main
ones having to do with implicit dereference (which occurs in this
notation,
as in any other selected_component notation). If you have a prefix of an
access type, it gets very messy to determine which dereference is which.
And
just allowing composite types doesn't work well either: a private type
that
is completed with an access type would *lose* operations when it had full
visibility -- that seems pretty weird.
It originally got limited to tagged types as that was easy to do and
didn't
have semantic issues.
what's i don't understand is, there is sth which work better with tagged types than with untagged types, whereas tagged types are known to be
more complex to give special functionnality, not to be simpler to use.
could you give me a concrete example please, of a case where using
prefix notation with an untagged type causes a particular problem, and
then making the type tagged permits to resolve the problem?
We were going to look at generalizing the prefix
notation again (several people asked about it), but no one made a
concrete
proposal and it never went anywhere for Ada 2022.
(maybe i could make one if i understand enough? :-) )
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 43:59:45 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,952 |