comp.lang.ada
 help / color / mirror / Atom feed
* Context syntax proposals, using "with", withing "use" etc.
@ 2003-12-22 23:53 Alexandre E. Kopilovitch
  2003-12-23 10:37 ` Martin Krischik
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre E. Kopilovitch @ 2003-12-22 23:53 UTC (permalink / raw)
  To: comp.lang.ada

After watching for some time the prolonged dances around "with and use",
I'm inclined to contribute to the topic.

First, I'd like to say that all the arguments concerned with repeating of a
package's name aren't serious at all: as for extra typing, this is a matter
of a text editor, not of the language; and as for a possibility of mistake
(that is, placing an unintended package's name in "use"), it is a matter of
a style and a corresponding style checker compiler option - you have little
chance to get such a mistake unnoticed with a quite simple rule: for example,
always place "use" and "with" in the same line, and never mix different
packages in the same line (compiler can easily verify that).

Second, there is still a displeasure here, which can even become a hindrance
in some circumsrances: when there are many context clauses for a package,
they just occupy too big part of the text; and because those context clauses
are necessarily at the beginning of each package, they intersperse and clutter
the whole program, which makes reading more difficult (even if each package
has its own window) - if one tried not to study thoroughly, but just to read
and catch the general method\logic\approach of the program.

So my guess is that the real reasons demanding the changes for "with" and
"use", if any, aren't about repeated package names, but actually about overall
amount of the text in (all) context clauses (and exclusion of repeated package
names simply decreases this amount).

Therefore I think that explicit separatation of the whole context from the
package's specs as well as from the package's body would be much more
consistent and useful step (than all possible manipulation with "with" and
"use" only) for the purpose. I mean something like that:

  package MyDream context is
  -- or package context MyDream is  - if you like it better
    with ...;
    with ...; use ...;
    ...
  end MyDream;

  package MyDream is
    ...
  end MyDream;

  package body MyDream context is
    with ...;
    with ...; use ...;
    ...
  end MyDream;

  package body MyDream is
    ...
  end MyDream;


Certainly there may be other syntactic forms for that separation, and extra
keyword ("context") may be avoided... although it seems in place there.



Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Context syntax proposals, using "with", withing "use" etc.
       [not found] <PnfFuv_SxF@VB1162.spb.edu>
@ 2003-12-23  9:02 ` Stephen Leake
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Leake @ 2003-12-23  9:02 UTC (permalink / raw)
  To: comp.lang.ada

"Alexandre E. Kopilovitch" <aek@VB1162.spb.edu> writes:

> Second, there is still a displeasure here, which can even become a
> hindrance in some circumsrances: when there are many context clauses
> for a package, they just occupy too big part of the text; and
> because those context clauses are necessarily at the beginning of
> each package, they intersperse and clutter the whole program, which
> makes reading more difficult (even if each package has its own
> window) - if one tried not to study thoroughly, but just to read and
> catch the general method\logic\approach of the program.

Hmm. I'd say this is also a text editor problem; the editor should
provide an easy way to put the cursor on the "package" keyword,
skipping the context clause. My Emacs Ada-mode does that. That's one
advantage of Ada over C; there is a clear end to the context clause.

> Therefore I think that explicit separatation of the whole context from the
> package's specs as well as from the package's body would be much more
> consistent and useful step (than all possible manipulation with "with" and
> "use" only) for the purpose. I mean something like that:
> 
>   package MyDream context is
>   -- or package context MyDream is  - if you like it better
>     with ...;
>     with ...; use ...;
>     ...
>   end MyDream;
> 
>   package MyDream is
>     ...
>   end MyDream;
> 
>   package body MyDream context is
>     with ...;
>     with ...; use ...;
>     ...
>   end MyDream;
> 
>   package body MyDream is
>     ...
>   end MyDream;

I don't see how this reduces clutter, or total size.  The text editor
still needs to be able to skip the context clause.


-- 
-- Stephe




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Context syntax proposals, using "with", withing "use" etc.
  2003-12-22 23:53 Context syntax proposals, using "with", withing "use" etc Alexandre E. Kopilovitch
@ 2003-12-23 10:37 ` Martin Krischik
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Krischik @ 2003-12-23 10:37 UTC (permalink / raw)


Alexandre E. Kopilovitch wrote:

> After watching for some time the prolonged dances around "with and use",
> I'm inclined to contribute to the topic.
 
[snip arguments]

To be honest, after about 2 or 3 weeks into learning Ada I have droped the
use of "use" inside the context alltogether. In fact a also dropped the use
of "use" in specifications as well.

I did this after finding two other features:

use type ...;

procedure Proc
is
    use ...;
begin
    ....
end Proc;

The reason was that it became very difficult for me to figure out where
which feature was provided, raising the learning curve significant.
Restricting the use of "use" as outlined above makes the programs a lot
easyer to read and it does un-clutter the context area as well.

So no need for change here.

With Regards

Martin

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-23 10:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-22 23:53 Context syntax proposals, using "with", withing "use" etc Alexandre E. Kopilovitch
2003-12-23 10:37 ` Martin Krischik
     [not found] <PnfFuv_SxF@VB1162.spb.edu>
2003-12-23  9:02 ` Stephen Leake

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