Hear me out, please, before you get the pitchforks ready. Testing the waters here.
Now, I’m surely not the first to complain about the with ... and use ... code repetition at the top of a file. And introducing a new keyword like import, for example, is not an easy task considering backwards compatibility and such, but what if we resort to a simple lowering by re-using what we have at our disposal?
Given that we can already write with clauses like this:
with A, B, C;
What if we allowed the following?
with and use Ada.Text_IO, Ada.Strings.Fixed, Foo.Bar.Baz;
It could then be simply lowered to the same old:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Foo.Bar.Baz; use Foo.Bar.Baz;
or to the equivalent:
with Ada.Text_IO, Ada.Strings.Fixed, Foo.Bar.Baz;
use Ada.Text_IO, Ada.Strings.Fixed, Foo.Bar.Baz;
Would this trigger any major side-effects? It requires changes to the grammar, sure, but it doesn’t introduce any keywords and shouldn’t have any impact on existing code since with and use isn’t legal, as far as I know.
Is anyone aware of any AIs that have discussed and dismissed such ideas before?
Pitchfork ? How cute. You meant the heavy flamethrower
Seriously, Use is already something you should be wary of, and employed as locally as possible, so a systematic with and use would be against the spirit of the language / good practices, and of little use in practical code as far as I’ve read. What you do is shoehorning habits from other languages, instead of adopting Ada’s own.
You can find ``Proposal for a “with and use” clause´´ in the Ada-Comment mailing list, from 2003 !..
There are also traces of that idea in comp.lang.ada: Clause "with and use" .
Back in the day the author (me) was used to the syntax of a famous Pascal dialect that uses “uses” with a similar meaning (but not the same exact semantics).
In the meantime, with growing projects and libraries, I appreciate the approach with only “with”, and using “use” 's the most locally possible.
A better proposal long ago was that use would simply imply with. So just:
use Ada.Text_IO;
You will find no support, since majority hate use clause being too lazy to design package specifications that would work with it. Then you cannot do it use-friendly with generics anyway.