comp.lang.ada
 help / color / mirror / Atom feed
* Ada95 tutorials with sample code.
@ 2001-03-05 20:40 mcdoobie
  2001-03-05 20:58 ` Erik Sigra
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: mcdoobie @ 2001-03-05 20:40 UTC (permalink / raw)


I've been browsing around the web checking out various Ada95 tutorials
and been pleased, yet somewhat frustrated.
Specifically, I'm looking for tutorials that offer alot of sample code
and practice excercises. It doesnt have to be some dumbed down spoon fed
fiasco, since I'm already familiar with Perl, Python, C, x86 ASM, and
Java. However, I learn better when I have sample code available to work
with.
Naturally, there is plenty of source available online, but my skills are
negligable at this point, hence most of the code usually ends up looking
more like gibberish to me.(I am able to disern what the code does and
some of the details of it's implementation, but most of the finer points
of semantics and such are lost on me.)
With that said, I am really excited about learning Ada95(specifically on
Linux 2.2.17 with Xfree4.01 on an AMD K6-3 processor) and will gladly
hobble along with free source until I reach a point that I can make heads
and tails out of it, but I'd rather not if it's unnecessary.

A good book is next on my list, as soon as I have some cash to spare.

Or, if someone is interested, I would gladly exchange something for a bit
of mentoring online.

Any advice would be greatly appreciated.

(Note: Although I can get around computer systems rather quickly with
some effort, I'm not a hacker/guru by any stretch of the imagination.
Hopefully that will be remedied shortly. Heh.)

Thanks

Chris
chainsaw two thousand at nospam dot home dot com



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

* Re: Ada95 tutorials with sample code.
  2001-03-05 20:40 mcdoobie
@ 2001-03-05 20:58 ` Erik Sigra
  2001-03-06  2:45 ` Jeffrey Carter
  2001-03-06 14:31 ` BSCrawford
  2 siblings, 0 replies; 32+ messages in thread
From: Erik Sigra @ 2001-03-05 20:58 UTC (permalink / raw)
  To: comp.lang.ada, mcdoobie

m�ndagen den  5 mars 2001 21:40 skrev mcdoobie:
> I've been browsing around the web checking out various Ada95 tutorials
> and been pleased, yet somewhat frustrated.
> Specifically, I'm looking for tutorials that offer alot of sample code
> and practice excercises. It doesnt have to be some dumbed down spoon fed
> fiasco, since I'm already familiar with Perl, Python, C, x86 ASM, and
> Java. However, I learn better when I have sample code available to work
> with.
> Naturally, there is plenty of source available online, but my skills are
> negligable at this point, hence most of the code usually ends up looking
> more like gibberish to me.(I am able to disern what the code does and
> some of the details of it's implementation, but most of the finer points
> of semantics and such are lost on me.)
> With that said, I am really excited about learning Ada95(specifically on
> Linux 2.2.17 with Xfree4.01 on an AMD K6-3 processor) and will gladly
> hobble along with free source until I reach a point that I can make heads
> and tails out of it, but I'd rather not if it's unnecessary.

Since you use Linux, <http://www.vaxxine.com/pegasoft/homes/book.html> is 
mandatory reading.

> A good book is next on my list, as soon as I have some cash to spare.

I have "programming in Ada95 2nd edition" by John Barnes. I think it is good.

> Or, if someone is interested, I would gladly exchange something for a bit
> of mentoring online.

I guess that's what this mailinglist/newsgroup is for.




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

* Re: Ada95 tutorials with sample code.
  2001-03-05 20:40 mcdoobie
  2001-03-05 20:58 ` Erik Sigra
@ 2001-03-06  2:45 ` Jeffrey Carter
  2001-03-06  7:12   ` Sven Nilsson
  2001-03-06 15:03   ` Marin David Condic
  2001-03-06 14:31 ` BSCrawford
  2 siblings, 2 replies; 32+ messages in thread
From: Jeffrey Carter @ 2001-03-06  2:45 UTC (permalink / raw)


mcdoobie wrote:
> 
> I've been browsing around the web checking out various Ada95 tutorials
> and been pleased, yet somewhat frustrated.
> Specifically, I'm looking for tutorials that offer alot of sample code
> and practice excercises. It doesnt have to be some dumbed down spoon fed
> fiasco, since I'm already familiar with Perl, Python, C, x86 ASM, and
> Java. However, I learn better when I have sample code available to work
> with.

If you have specific examples in mind, I'm sure people here will offer
you their versions. Here's everyone's 1st program:

-- "Hello, World!" program in Ada

with Ada.Text_IO;

use Ada.Text_IO;
procedure Hello_World is
   -- null;
begin -- Hello_World
   Put_Line (Item => "Hello, World!");
end Hello_World;

-- 
Jeff Carter
"You brightly-colored, mealy-templed, cranberry-smelling, electric
donkey-bottom biters."
Monty Python & the Holy Grail



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

* Re: Ada95 tutorials with sample code.
  2001-03-06  2:45 ` Jeffrey Carter
@ 2001-03-06  7:12   ` Sven Nilsson
  2001-03-06  8:09     ` tmoran
                       ` (8 more replies)
  2001-03-06 15:03   ` Marin David Condic
  1 sibling, 9 replies; 32+ messages in thread
From: Sven Nilsson @ 2001-03-06  7:12 UTC (permalink / raw)


I'm sorry if I disrupt this thread with a slightly off-topic question
(which I'm sure has been discussed countless times before) BUT

This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
projects with loads of people writing the code and I've found that the
use-clause can be a real pain as it dosn't give you a clue as to where
things are declared. Right now I'm teaching new arrivals about Ada 95
and I invariably tell them NOT to use the use-clause. 
Now, there're a lot of very clever and skilled people reading this
news-group and I'd be interested in your feelings on "use". Is it a Do
or Don't? Generally speaking?

My Hello World would probably look something like this:

-- "Hello, World"

with Ada.Text_IO;

procedure Hello_World is
package Tio renames Ada.Text_IO; -- Rename common packages so I don't
have to 
                                 -- type in the whole thing every time I
use it
begin
   Tio.Put_Line("Howdy, World!"); -- Use Tio to access Ada.Text_IO
end Hello_World;

> -- "Hello, World!" program in Ada
> 
> with Ada.Text_IO;
> 
> use Ada.Text_IO;
> procedure Hello_World is
>    -- null;
> begin -- Hello_World
>    Put_Line (Item => "Hello, World!");
> end Hello_World;
>

-Sven



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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
@ 2001-03-06  8:09     ` tmoran
  2001-03-06 10:38     ` David C. Hoos, Sr.
                       ` (7 subsequent siblings)
  8 siblings, 0 replies; 32+ messages in thread
From: tmoran @ 2001-03-06  8:09 UTC (permalink / raw)


> and I invariably tell them NOT to use the use-clause.
"invariably" seems rather strong, but I *rarely* use use-clauses.
What does "Ada Quality and Style" suggest?

>  Tio.Put_Line("Howdy, World!"); -- Use Tio to access Ada.Text_IO
 Or you could type it in that way, then tell your editor to change
Tio to Ada.Text_IO globally.



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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
  2001-03-06  8:09     ` tmoran
@ 2001-03-06 10:38     ` David C. Hoos, Sr.
  2001-03-06 10:38     ` David C. Hoos, Sr.
                       ` (6 subsequent siblings)
  8 siblings, 0 replies; 32+ messages in thread
From: David C. Hoos, Sr. @ 2001-03-06 10:38 UTC (permalink / raw)


The "use" clause was desirable in limited circumstances in
Ada83. My personal rule was to use a "use" clause only
to make infix operators visible -- i.i. to avoid having to
write A := My_Package."+"(B, C);
instead of the more readable A := B + C;

With Ada95, even this is not necessary, since one can use
the "use type" clause.

In either Ada83 or Ada95, the use of a renames clause to
abbreviate log names is useful, as you have done in your
example.

The Ada95 Quality and Style Guide (available from
http://www.adaic.org/AdaIC/docs/style-guide/95style/zip/)
has this to say about the "use" clause:

Chapter 5: Programming Practices - TOC - 5.7 VISIBILITY
5.7.1 The Use Clause
guideline
When you need to provide visibility to operators, use the use type clause.
Avoid/minimize the use of the use clause (Nissen and Wallis 1984).
Consider using a package renames clause rather than a use clause for a
package.
Consider using the use clause in the following situations:
- When standard packages are needed and no ambiguous references are
introduced
- When references to enumeration literals are needed
Localize the effect of all use clauses.

"Sven Nilsson" <emwsvni@emw.ericsson.se> wrote in message
news:3AA48DE9.A0650F21@emw.ericsson.se...
> I'm sorry if I disrupt this thread with a slightly off-topic question
> (which I'm sure has been discussed countless times before) BUT
>
> This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
> projects with loads of people writing the code and I've found that the
> use-clause can be a real pain as it dosn't give you a clue as to where
> things are declared. Right now I'm teaching new arrivals about Ada 95
> and I invariably tell them NOT to use the use-clause.
> Now, there're a lot of very clever and skilled people reading this
> news-group and I'd be interested in your feelings on "use". Is it a Do
> or Don't? Generally speaking?
>
> My Hello World would probably look something like this:
>
> -- "Hello, World"
>
> with Ada.Text_IO;
>
> procedure Hello_World is
> package Tio renames Ada.Text_IO; -- Rename common packages so I don't
> have to
>                                  -- type in the whole thing every time I
> use it
> begin
>    Tio.Put_Line("Howdy, World!"); -- Use Tio to access Ada.Text_IO
> end Hello_World;
>
> > -- "Hello, World!" program in Ada
> >
> > with Ada.Text_IO;
> >
> > use Ada.Text_IO;
> > procedure Hello_World is
> >    -- null;
> > begin -- Hello_World
> >    Put_Line (Item => "Hello, World!");
> > end Hello_World;
> >
>
> -Sven




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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
  2001-03-06  8:09     ` tmoran
  2001-03-06 10:38     ` David C. Hoos, Sr.
@ 2001-03-06 10:38     ` David C. Hoos, Sr.
  2001-03-06 15:06       ` Ted Dennison
  2001-03-06 15:29     ` Robert A Duff
                       ` (5 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: David C. Hoos, Sr. @ 2001-03-06 10:38 UTC (permalink / raw)


The "use" clause was desirable in limited circumstances in
Ada83. My personal rule was to use a "use" clause only
to make infix operators visible -- i.i. to avoid having to
write A := My_Package."+"(B, C);
instead of the more readable A := B + C;

With Ada95, even this is not necessary, since one can use
the "use type" clause.

In either Ada83 or Ada95, the use of a renames clause to
abbreviate log names is useful, as you have done in your
example.

The Ada95 Quality and Style Guide (available from
http://www.adaic.org/AdaIC/docs/style-guide/95style/zip/)
has this to say about the "use" clause:

Chapter 5: Programming Practices - TOC - 5.7 VISIBILITY
5.7.1 The Use Clause
guideline
When you need to provide visibility to operators, use the use type clause.
Avoid/minimize the use of the use clause (Nissen and Wallis 1984).
Consider using a package renames clause rather than a use clause for a
package.
Consider using the use clause in the following situations:
- When standard packages are needed and no ambiguous references are
introduced
- When references to enumeration literals are needed
Localize the effect of all use clauses.

"Sven Nilsson" <emwsvni@emw.ericsson.se> wrote in message
news:3AA48DE9.A0650F21@emw.ericsson.se...
> I'm sorry if I disrupt this thread with a slightly off-topic question
> (which I'm sure has been discussed countless times before) BUT
>
> This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
> projects with loads of people writing the code and I've found that the
> use-clause can be a real pain as it dosn't give you a clue as to where
> things are declared. Right now I'm teaching new arrivals about Ada 95
> and I invariably tell them NOT to use the use-clause.
> Now, there're a lot of very clever and skilled people reading this
> news-group and I'd be interested in your feelings on "use". Is it a Do
> or Don't? Generally speaking?
>
> My Hello World would probably look something like this:
>
> -- "Hello, World"
>
> with Ada.Text_IO;
>
> procedure Hello_World is
> package Tio renames Ada.Text_IO; -- Rename common packages so I don't
> have to
>                                  -- type in the whole thing every time I
> use it
> begin
>    Tio.Put_Line("Howdy, World!"); -- Use Tio to access Ada.Text_IO
> end Hello_World;
>
> > -- "Hello, World!" program in Ada
> >
> > with Ada.Text_IO;
> >
> > use Ada.Text_IO;
> > procedure Hello_World is
> >    -- null;
> > begin -- Hello_World
> >    Put_Line (Item => "Hello, World!");
> > end Hello_World;
> >
>
> -Sven




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

* Re: Ada95 tutorials with sample code.
  2001-03-05 20:40 mcdoobie
  2001-03-05 20:58 ` Erik Sigra
  2001-03-06  2:45 ` Jeffrey Carter
@ 2001-03-06 14:31 ` BSCrawford
  2001-03-06 22:38   ` mcdoobie
  2 siblings, 1 reply; 32+ messages in thread
From: BSCrawford @ 2001-03-06 14:31 UTC (permalink / raw)


<mcdoobie@hotmail.com> writes: (in part)

>Specifically, I'm looking for tutorials that offer alot of sample code
>and practice excercises.

Take a look at www.LearnAda.com  

My book "Ada Essentials: Overview, Examples and Glossary" 
is available in three forms: printed book, PDF version and HTML version. 

The two electronic versions cost only $12.  The HTML version 
(an online tutorial) has many hyperlinks, making it easy to find 
examples illustrating specific language features. 

Bard Crawford
Stage Harbor Software






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

* Re: Ada95 tutorials with sample code.
  2001-03-06  2:45 ` Jeffrey Carter
  2001-03-06  7:12   ` Sven Nilsson
@ 2001-03-06 15:03   ` Marin David Condic
  1 sibling, 0 replies; 32+ messages in thread
From: Marin David Condic @ 2001-03-06 15:03 UTC (permalink / raw)


My web page appears to be back in working order. You might want to look at
some of the example code that appears on my Ada Programming page. (Start at:
http://www.mcondic.com/)

I have a bunch of small Ada programs that I used in conjunction with an
internal training course I taught. They make more sense within the context
of the course, but they may serve well to provide some small, easily
manipulated programs that assist in learning the language. Look for the
"Gnat Examples" code on my Ada Programming page.

Hope this is useful...

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/





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

* Re: Ada95 tutorials with sample code.
  2001-03-06 10:38     ` David C. Hoos, Sr.
@ 2001-03-06 15:06       ` Ted Dennison
  0 siblings, 0 replies; 32+ messages in thread
From: Ted Dennison @ 2001-03-06 15:06 UTC (permalink / raw)


In article <5l3p6.160282$Ch.32975101@newsrump.sjc.telocity.net>, David C. Hoos,
Sr. says...
>
>The "use" clause was desirable in limited circumstances in
>Ada83. My personal rule was to use a "use" clause only
>to make infix operators visible -- i.i. to avoid having to
>write A := My_Package."+"(B, C);
>instead of the more readable A := B + C;

I wouldn't even do that. You can achieve the same effect by using a function
renames:

function "+" (Left, Right : My_Package.My_Type) return My_Package.My_Type
renames My_Package."+";

Fortunately, Ada95's "use type" renders most of this discussion moot.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
                       ` (2 preceding siblings ...)
  2001-03-06 10:38     ` David C. Hoos, Sr.
@ 2001-03-06 15:29     ` Robert A Duff
  2001-03-06 16:54       ` Ted Dennison
  2001-03-06 15:48     ` Ted Dennison
                       ` (4 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: Robert A Duff @ 2001-03-06 15:29 UTC (permalink / raw)


Sven Nilsson <emwsvni@emw.ericsson.se> writes:

> I'm sorry if I disrupt this thread with a slightly off-topic question
> (which I'm sure has been discussed countless times before) BUT

Yes, it has been discussed many times.  There is basically no agreement:
some folks like to use "use" almost all the time, other folks almost
never.  And some folks advocate renamings, as you suggest:

> package Tio renames Ada.Text_IO; -- Rename common packages so I don't
> have to 
>                                  -- type in the whole thing every time I
> use it

Some folks (including me) think that the renaming solution gives you the
worst of both worlds: the "Tio." is just noise, because it doesn't tell
me *anything*.  I'd rather have "Put_Line(...)" or
"Text_IO.Put_Line(...)".

After all, if "Tio" were a reasonable name for this thing, why didn't
Jean Ichbiah call it that in the first place?

(Note: I always have "use Ada;", so I would never say
"Ada.Text_IO.Put_Line(...);".)

(Another note: the rationale above, "so I don't have to type in the
whole thing...", is a poor reason to do *anything*.  If you said, "so I
don't have to read all that extra verbiage..." it might make sense.  The
cost of making computer programs has approximately nothing to do with
how much typing is involved.)

Another point is that the person who writes the package has to decide
whether clients should say "use" of that package, because it makes a big
difference in how names of things in that package are chosen.  It makes
no sense to say "never use use" if the package you're importing was
written with use clauses in mind.

- Bob



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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
                       ` (3 preceding siblings ...)
  2001-03-06 15:29     ` Robert A Duff
@ 2001-03-06 15:48     ` Ted Dennison
  2001-03-06 18:19       ` Robert A Duff
  2001-03-06 18:20     ` Jean-Pierre Rosen
                       ` (3 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: Ted Dennison @ 2001-03-06 15:48 UTC (permalink / raw)


In article <3AA48DE9.A0650F21@emw.ericsson.se>, Sven Nilsson says...
>
>(which I'm sure has been discussed countless times before) BUT
ohhhhh yeah.....

>This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
>projects with loads of people writing the code and I've found that the
>use-clause can be a real pain as it dosn't give you a clue as to where
>things are declared. Right now I'm teaching new arrivals about Ada 95
>and I invariably tell them NOT to use the use-clause. 
>Now, there're a lot of very clever and skilled people reading this
>news-group and I'd be interested in your feelings on "use". Is it a Do
>or Don't? Generally speaking?

That's a subject of much (often vitrolic) debate. Personally, I'm with you. Most
of my Ada projects are in the >100KSLOC range and I *lothe* use clauses. This is
probably partly because I often get called in to try to figure out what's going
on in the worst-written code in the system, thus I don't get a chance to see
them used well (assuming there really is such a thing. :-) ).

I should also mention that none of this goes for the "use type" feature of
Ada95, which IMHO is the best thing since sliced bread. :-)

I see that most of the other responses so far are along this same line. Its a
shame Dr. Dewar (of NYU and Gnat fame) never came back after Deja went under,
because he could probably give you the best pro-use argument. If I remember
right, one of the main pro-use compaints is that with the new child package
feature, names just get rediculous if you are pedantic about "no uses". 

The common example used is Ada.Strings.Unbounded.To_Unbounded_String. Even I
have to admit this looks stupid. However, I'd claim that the stupidity is
entirely a result of stupid naming on the designers part. They quite easily
could have named the routine Ada.Strings.Unbounded.To, rather than repeating the
names of two parent packages in the subprogram's identifier.

Another point I remember Dr. Dewar making is that some modern compilers (eg:
Gnat) have features that allow you to find the declaration of any object in the
editor. My argument is that this only works if you are always reading the
sources in the editor (eg: no printouts), and only when the code is in a
compilable state. Also, it doesn't help with those situations where a reader
might incorrectly think that they know where an object is comming from and
therefore not check.

Rather than teach folks that "use is evil" (as I do :-)  ), I'd suggest that you
take the following approach:

o  Point out that many (most?) large projects either forbid or severly restrict
the use of this feature due to supposed maintainability issues. 

o  Try to mention all sides of the debate. Feel free to give your personal
stance as well. :-)

o  You may want to consider making a class style-guide for assigned work, if one
style particularly bothers you.

o  Emphasise that anyone writing software that might be used by someone else
operating under different use-clause rules (eg: reusable components or
libraries) should be very sensitive to the names they give things. In
particular, restating the name of the package (or a parent package) in an
identifier should be avioded. If the names of the parent packages is considered
important, the user can use the full notation. 

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



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

* Re: Ada95 tutorials with sample code.
  2001-03-06 15:29     ` Robert A Duff
@ 2001-03-06 16:54       ` Ted Dennison
  0 siblings, 0 replies; 32+ messages in thread
From: Ted Dennison @ 2001-03-06 16:54 UTC (permalink / raw)


In article <wccitlmrk4s.fsf@world.std.com>, Robert A Duff says...
>Some folks (including me) think that the renaming solution gives you the
>worst of both worlds: the "Tio." is just noise, because it doesn't tell
>me *anything*.  I'd rather have "Put_Line(...)" or
>"Text_IO.Put_Line(...)".

I'm with you on that one; definitely the worst of both worlds. However, I'd have
to think on it a while before I could decide which is worse (terse rename, or
use clause) on a package less well-known than Text_IO.

>Another point is that the person who writes the package has to decide
>whether clients should say "use" of that package, because it makes a big
>difference in how names of things in that package are chosen.  It makes
>no sense to say "never use use" if the package you're importing was
>written with use clauses in mind.

Many large projects forbid the use clause; that is a fact. Another fact is that
it is possible to create names that work well with both, and thus that is the
goal that should generally be strived for. Failing that, a developer should
shoot for names that look decent w/o use clauses, as many large projects force
that style on the developers, but none (I have ever heard of) prevent package
dot notation. Someone using a "use" clause can still selectively use the dot
notation to make things look ok if they want. Developers should never write
packages "with use clauses in mind", unless they are certain that they will
never be used outside of their current development environment.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



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

* Re: Ada95 tutorials with sample code.
  2001-03-06 15:48     ` Ted Dennison
@ 2001-03-06 18:19       ` Robert A Duff
  2001-03-06 21:19         ` Ted Dennison
  2001-03-08  6:13         ` Simon Wright
  0 siblings, 2 replies; 32+ messages in thread
From: Robert A Duff @ 2001-03-06 18:19 UTC (permalink / raw)


Ted Dennison<dennison@telepath.com> writes:

> The common example used is Ada.Strings.Unbounded.To_Unbounded_String. Even I
> have to admit this looks stupid. However, I'd claim that the stupidity is
> entirely a result of stupid naming on the designers part. They quite easily
> could have named the routine Ada.Strings.Unbounded.To, ...

Is this supposed to be an example of a name that works well both with
and without use clauses?  Yikes.

>...rather than repeating the
> names of two parent packages in the subprogram's identifier.

I think it's repeating the name of a *type*, not packages.

- Bob



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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
                       ` (4 preceding siblings ...)
  2001-03-06 15:48     ` Ted Dennison
@ 2001-03-06 18:20     ` Jean-Pierre Rosen
  2001-03-06 20:10       ` Erik Sigra
  2001-03-06 21:47       ` Ted Dennison
  2001-03-07  0:11     ` Robert C. Leif, Ph.D.
                       ` (2 subsequent siblings)
  8 siblings, 2 replies; 32+ messages in thread
From: Jean-Pierre Rosen @ 2001-03-06 18:20 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]


"Sven Nilsson" <emwsvni@emw.ericsson.se> a �crit dans le message news: 3AA48DE9.A0650F21@emw.ericsson.se...
> I'm sorry if I disrupt this thread with a slightly off-topic question
> (which I'm sure has been discussed countless times before) BUT
>
> This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
> projects with loads of people writing the code and I've found that the
> use-clause can be a real pain as it dosn't give you a clue as to where
> things are declared. Right now I'm teaching new arrivals about Ada 95
> and I invariably tell them NOT to use the use-clause.
> Now, there're a lot of very clever and skilled people reading this
> news-group and I'd be interested in your feelings on "use". Is it a Do
> or Don't? Generally speaking?
>
Have a look at my paper "In Defense of the Use Clause", available from http://www.adalog.fr/publica2.htm

And note the URL! Adalog, at long last, got its own domain!

--
---------------------------------------------------------
           J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://www.adalog.fr





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

* Re: Ada95 tutorials with sample code.
  2001-03-06 18:20     ` Jean-Pierre Rosen
@ 2001-03-06 20:10       ` Erik Sigra
  2001-03-07 14:31         ` Simon Pilgrim
  2001-03-06 21:47       ` Ted Dennison
  1 sibling, 1 reply; 32+ messages in thread
From: Erik Sigra @ 2001-03-06 20:10 UTC (permalink / raw)
  To: comp.lang.ada, Jean-Pierre Rosen

tisdagen den  6 mars 2001 19:20 skrev Jean-Pierre Rosen:
> "Sven Nilsson" <emwsvni@emw.ericsson.se> a �crit dans le message news:
> 3AA48DE9.A0650F21@emw.ericsson.se...
>
> > I'm sorry if I disrupt this thread with a slightly off-topic question
> > (which I'm sure has been discussed countless times before) BUT
> >
> > This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
> > projects with loads of people writing the code and I've found that the
> > use-clause can be a real pain as it dosn't give you a clue as to where
> > things are declared. Right now I'm teaching new arrivals about Ada 95
> > and I invariably tell them NOT to use the use-clause.
> > Now, there're a lot of very clever and skilled people reading this
> > news-group and I'd be interested in your feelings on "use". Is it a Do
> > or Don't? Generally speaking?
>
> Have a look at my paper "In Defense of the Use Clause", available from
> http://www.adalog.fr/publica2.htm

Should java be required to see the document?




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

* Re: Ada95 tutorials with sample code.
  2001-03-06 18:19       ` Robert A Duff
@ 2001-03-06 21:19         ` Ted Dennison
  2001-03-08  6:13         ` Simon Wright
  1 sibling, 0 replies; 32+ messages in thread
From: Ted Dennison @ 2001-03-06 21:19 UTC (permalink / raw)


In article <wcchf16rca2.fsf@world.std.com>, Robert A Duff says...
>
>Ted Dennison<dennison@telepath.com> writes:
>
>> The common example used is Ada.Strings.Unbounded.To_Unbounded_String. Even I
>> have to admit this looks stupid. However, I'd claim that the stupidity is
>> entirely a result of stupid naming on the designers part. They quite easily
>> could have named the routine Ada.Strings.Unbounded.To, ...
>
>Is this supposed to be an example of a name that works well both with
>and without use clauses?  Yikes.

No, its pretty clearly an example that works best with full named-notation.
Getting something that looks beautiful with both would take more consideration
that I was willing to give to a quick post. :-)

However, suppose it were my atrocious "To". There would be absolutely nothing
stopping someone who has a "use Ada.Strings.Unbounded;" from writing
"Unbounded.To" or "Strings.Unbounded.To", where now they write
"To_Unbounded_String". However, someone who doesn't have a "use
Ada.Strings.Unbounded;" is currently *forced* to write the stupid-looking
"Ada.Strings.Unbounded.To_Unbounded_String".

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



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

* Re: Ada95 tutorials with sample code.
  2001-03-06 18:20     ` Jean-Pierre Rosen
  2001-03-06 20:10       ` Erik Sigra
@ 2001-03-06 21:47       ` Ted Dennison
  1 sibling, 0 replies; 32+ messages in thread
From: Ted Dennison @ 2001-03-06 21:47 UTC (permalink / raw)


In article <sia389.rvg.ln@skymaster.axlog.fr>, Jean-Pierre Rosen says...
>
>Have a look at my paper "In Defense of the Use Clause", available from http://www.adalog.fr/publica2.htm

I have read it before, and obviously I don't agree entirely with the paper.
However, I do like the part at the end where you advocate localizing "use"
clauses to subprograms. I think it would be a much more useful contribution to
the pro-use clause world if more information like this was available. I'd really
like to see more detailed guidelines on the "proper use" of use clauses.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



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

* Re: Ada95 tutorials with sample code.
  2001-03-06 14:31 ` BSCrawford
@ 2001-03-06 22:38   ` mcdoobie
  0 siblings, 0 replies; 32+ messages in thread
From: mcdoobie @ 2001-03-06 22:38 UTC (permalink / raw)


I'm definitely gonna check it out, in addition to the www.mcondic.com
website mentioned in another post.

Now I have a quick question. I'm using a loop to test for the existence
of a certain variable, but I'm not quite sure how to go about it.  Heres
what it looks like right now...

while opt_is not 'V' or 'A' loop
	Put( opt_prompt );
	NEW_LINE;
	Ada.Text_IO.Put_Line( "Please enter either a 'V' or an 'A' );
	Get( opt_is );
end loop;

Now, I'm not sure what I'm supposed to be doing at the start of the loop.
 Any help woiuld be appreciated.

Thanks.

McDoobie
mcdoobie@hotmail.com



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

* RE: Ada95 tutorials with sample code.
@ 2001-03-06 23:51 Beard, Frank
  0 siblings, 0 replies; 32+ messages in thread
From: Beard, Frank @ 2001-03-06 23:51 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'

Without caring or trying to figure out why,
to answer what I think your question is:

with Ada.Characters.Handling;  use Ada.Characters.Handling;

procedure Xyz is

  opt_is : character := ' ';

begin

  opt_is := To_Upper(opt_is);
  while opt_is /= 'V' and then opt_is /= 'A' loop
    Put( opt_prompt );
    NEW_LINE;
    Ada.Text_IO.Put_Line( "Please enter either a 'V' or an 'A' );
    Get( opt_is );
  end loop;

end Xyz;


-----Original Message-----
From: mcdoobie [mailto:chainsaw.two.thousand@nospam.dot.home.dot.com]
Sent: Tuesday, March 06, 2001 5:39 PM
To: comp.lang.ada@ada.eu.org
Subject: Re: Ada95 tutorials with sample code.


I'm definitely gonna check it out, in addition to the www.mcondic.com
website mentioned in another post.

Now I have a quick question. I'm using a loop to test for the existence
of a certain variable, but I'm not quite sure how to go about it.  Heres
what it looks like right now...

while opt_is not 'V' or 'A' loop
	Put( opt_prompt );
	NEW_LINE;
	Ada.Text_IO.Put_Line( "Please enter either a 'V' or an 'A' );
	Get( opt_is );
end loop;

Now, I'm not sure what I'm supposed to be doing at the start of the loop.
 Any help woiuld be appreciated.

Thanks.

McDoobie
mcdoobie@hotmail.com
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada




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

* RE: Ada95 tutorials with sample code.
@ 2001-03-06 23:58 Beard, Frank
  0 siblings, 0 replies; 32+ messages in thread
From: Beard, Frank @ 2001-03-06 23:58 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'

Oops!  Forgot to move a statement after cut-and-paste.


with Ada.Characters.Handling;  use Ada.Characters.Handling;

procedure Xyz is

  opt_is : character := ' ';

begin

  while opt_is /= 'V' and then opt_is /= 'A' loop
    Put( opt_prompt );
    NEW_LINE;
    Ada.Text_IO.Put_Line( "Please enter either a 'V' or an 'A' );
    Get( opt_is );
    opt_is := To_Upper(opt_is);
  end loop;

end Xyz;


-----Original Message-----
From: mcdoobie [mailto:chainsaw.two.thousand@nospam.dot.home.dot.com]
Sent: Tuesday, March 06, 2001 5:39 PM
To: comp.lang.ada@ada.eu.org
Subject: Re: Ada95 tutorials with sample code.


I'm definitely gonna check it out, in addition to the www.mcondic.com
website mentioned in another post.

Now I have a quick question. I'm using a loop to test for the existence
of a certain variable, but I'm not quite sure how to go about it.  Heres
what it looks like right now...

while opt_is not 'V' or 'A' loop
	Put( opt_prompt );
	NEW_LINE;
	Ada.Text_IO.Put_Line( "Please enter either a 'V' or an 'A' );
	Get( opt_is );
end loop;

Now, I'm not sure what I'm supposed to be doing at the start of the loop.
 Any help woiuld be appreciated.

Thanks.

McDoobie
mcdoobie@hotmail.com
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada

_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada




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

* RE: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
                       ` (5 preceding siblings ...)
  2001-03-06 18:20     ` Jean-Pierre Rosen
@ 2001-03-07  0:11     ` Robert C. Leif, Ph.D.
  2001-03-07  6:44     ` Jeffrey Carter
  2001-03-07  7:54     ` Sven Nilsson
  8 siblings, 0 replies; 32+ messages in thread
From: Robert C. Leif, Ph.D. @ 2001-03-07  0:11 UTC (permalink / raw)
  To: comp.lang.ada

From: Bob Leif
To: Sven Nilsson et al.

In general, I agree that the excessive Use clauses can be a real pain when
it comes to understanding or maintaining Ada source.
I have suggested that a Table of Contents comment (annotation) before the
package renames section and an End Table of Contents afterwards would be a
much better way to communicate. I would also like and would pay a reasonable
price for a an ASIS tool that undid the Use clauses. It  could be named
Pragma No_Use.

-----Original Message-----
From: comp.lang.ada-admin@ada.eu.org
[mailto:comp.lang.ada-admin@ada.eu.org]On Behalf Of Sven Nilsson
Sent: Monday, March 05, 2001 11:13 PM
To: comp.lang.ada@ada.eu.org
Subject: Re: Ada95 tutorials with sample code.


I'm sorry if I disrupt this thread with a slightly off-topic question
(which I'm sure has been discussed countless times before) BUT

This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
projects with loads of people writing the code and I've found that the
use-clause can be a real pain as it dosn't give you a clue as to where
things are declared. Right now I'm teaching new arrivals about Ada 95
and I invariably tell them NOT to use the use-clause.
Now, there're a lot of very clever and skilled people reading this
news-group and I'd be interested in your feelings on "use". Is it a Do
or Don't? Generally speaking?

My Hello World would probably look something like this:

-- "Hello, World"

with Ada.Text_IO;

procedure Hello_World is
package Tio renames Ada.Text_IO; -- Rename common packages so I don't
have to
                                 -- type in the whole thing every time I
use it
begin
   Tio.Put_Line("Howdy, World!"); -- Use Tio to access Ada.Text_IO
end Hello_World;

> -- "Hello, World!" program in Ada
>
> with Ada.Text_IO;
>
> use Ada.Text_IO;
> procedure Hello_World is
>    -- null;
> begin -- Hello_World
>    Put_Line (Item => "Hello, World!");
> end Hello_World;
>

-Sven





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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
                       ` (6 preceding siblings ...)
  2001-03-07  0:11     ` Robert C. Leif, Ph.D.
@ 2001-03-07  6:44     ` Jeffrey Carter
  2001-03-07  7:54     ` Sven Nilsson
  8 siblings, 0 replies; 32+ messages in thread
From: Jeffrey Carter @ 2001-03-07  6:44 UTC (permalink / raw)


Sven Nilsson wrote:
> 
> I'm sorry if I disrupt this thread with a slightly off-topic question
> (which I'm sure has been discussed countless times before) BUT
> 
> This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
> projects with loads of people writing the code and I've found that the
> use-clause can be a real pain as it dosn't give you a clue as to where
> things are declared. Right now I'm teaching new arrivals about Ada 95
> and I invariably tell them NOT to use the use-clause.
> Now, there're a lot of very clever and skilled people reading this
> news-group and I'd be interested in your feelings on "use". Is it a Do
> or Don't? Generally speaking?

You're right: This has been discussed to death several times. Judging by
the number of responses you got, we're going to discuss it to death
again.

My rule is: use "use" when it makes the code easier to read. I assume
everyone using Ada is familiar with Ada.Text_IO, so I have no problem
with using it. People will know where Put, Get, and so on come from.

Some packages are designed to be used; a good example is
Ada.Strings.Unbounded. There is a type "Unbounded_String" and an
operation "To_Unbounded_String", for example. It is obvious where these
come from, so "use" is appropriate. Not using these packages results in
redundant names such as Strings.Unbounded.Unbounded_String, which I
think is less readable than using the package.

Other packages are intended NOT to be used. Using these packages will
make your code impossible to understand. As an example, the PragmAda
Reusable Components (see

http://home.earthlink.net/~jrcarter010/pragmarc.htm

or the mirror at www.adapower.com) have a number of ADTs with the type
named "Handle". Obviously, using (an instantiation of) one of these will
get ugly pretty quickly. Using more than one will make you use the
package names anyway.

-- 
Jeff Carter
"Son of a window-dresser."
Monty Python & the Holy Grail



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

* Re: Ada95 tutorials with sample code.
  2001-03-06  7:12   ` Sven Nilsson
                       ` (7 preceding siblings ...)
  2001-03-07  6:44     ` Jeffrey Carter
@ 2001-03-07  7:54     ` Sven Nilsson
  2001-03-07 15:10       ` Marin David Condic
  2001-03-08  0:05       ` Mark Lundquist
  8 siblings, 2 replies; 32+ messages in thread
From: Sven Nilsson @ 2001-03-07  7:54 UTC (permalink / raw)


Howdy

I'm replying to my own entry here to try and recap some of the things
thats been said. No flaming at all as far as I can see, thank you very
much people!

Most people seem to agree that the use-clause can be a dangerous thing,
but there are voices raised in it's defence:

1. If you write/design your code properly, the use-clause won't be a
problem and will make the program easier to read and maintain.
2. Standard things like Text_Io and Strings should be known to most
Ada-users and in that case a use-clause can be used safely.
3. Using full names means the code will be less readable (this is noted
in the paper "In defence of the use clause" available at
http://www.adalog.fr/publica2.htm and is consistent with what I know of
readablility index and such things (I'm a teacher at heart))

All of these are good solid reasons to use "use", but I do not agree
with them.
The first one would be nice if it worked, but in my experience people
don't think before they do. As I said in my last post, I work in big
projects with a lot of people working on the same code in different
teams, trusting that everyone has the same view of what is proper design
is bordering on stupidity. "Trust is good, control is better" as the old
saying goes.
The second one should be very true indeed. My example in the other post
(with TIO) is pretty stupid, really. BUT clever chaps tend to override
standard things like text_io and strings to add little extra features.
Like Ted I'm often called in to  figure out why things don't work and
I've actually had a case where a badly implemented debug-text_io was the
whole problem...
The third statement is probably the hardest to argue with. Having spent
the last three years reading and writing Ada-code using full names, I've
gown pretty used to "filtering" out the prefixes until I need them, but
as a beginner the code always seemed horrible complicated. That's a
problem...

Other notes that I feel should be pointed out again is

4. The option of "use type", which I agree can be VERY usefull on
occasion.
5. Using "use" in the procedures/functions where it is really needed.

Number 5 is perhaps the way to go. If we can keep our methods (to use a
java term) short (as in K.I.S.S), this could become very readable AND
traceable. I'll have to look into that one further.

The last point I'd like to recap is concerning renaming. Some people
obviously consider this to be the worst thing to befall mankind and
about two years ago I would have agreed. Now, however, we've been using
rename for so long and so extensively that we actually have "renaming
conventions". Almost every file you open have a number of renames at the
top, renaming standard packages that we use extensively. These renames
are ALWAYS the same, which means that it actually becomes quite
readable. So why didn't we name the packages that way to start with, you
might ask. Simple. I know what TEPC is, but you don't. It really is a
package name of some 30 characters (yes, that long) which I don't want
to type and certainly don't want to read everytime it's used, but TEPC
is ok to read and it tells me what I need to know. If you don't know
what TEPC is, you just look it up in the rename section of the package.
This works, but I agree that it's not a perfect world...

So much for the recap. Thank you for all the comments, I'll ponder over
them as I look over our naming conventions and coding principles.

-Sven



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

* Re: Ada95 tutorials with sample code.
       [not found] <01030621102401.00302@a77>
@ 2001-03-07 12:09 ` Mario Amado Alves
  0 siblings, 0 replies; 32+ messages in thread
From: Mario Amado Alves @ 2001-03-07 12:09 UTC (permalink / raw)
  To: comp.lang.ada; +Cc: Jean-Pierre Rosen

> > Have a look at my paper "In Defense of the Use Clause", available from
> > http://www.adalog.fr/publica2.htm

> Should java be required to see the document?

Of course. Dont you know we non-java-enabled-browser users are practically
extinct ;-)

/* Why dont we use java-enabled-browsers? Well, in my case, I cannot use
Nestcape because it terminates abnormally and leaves my system in a bad
shape. I cannot use IE because mine is a Linux box. So I must use Lynx and
Amaya. */

On May 12 I will deliver my Web Quality Manifesto at QUATIC'2001 in
Lisbon:

  http://www.esw.inesc.pt/quatic2001

(Note the cool Java applets ;-)

| |,| | | |RuaFranciscoTaborda24RcD 2815-249CharnecaCaparica 351+939354005
|M|A|R|I|O|
|A|M|A|D|O|DepartmentoDeInformaticaFCT/UNL 2825-114 Caparica 351+212958536
|A|L|V|E|S|                                                  fax 212948541
| | | | | |                 maa@di.fct.unl.pt                FCT 212948300





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

* Re: Ada95 tutorials with sample code.
       [not found] <Pine.LNX.4.10.10103071153320.971-100000@lexis.di.fct.unl.pt>
@ 2001-03-07 13:12 ` Erik Sigra
  2001-03-07 18:07   ` Jean-Pierre Rosen
  0 siblings, 1 reply; 32+ messages in thread
From: Erik Sigra @ 2001-03-07 13:12 UTC (permalink / raw)
  To: comp.lang.ada, Mario Amado Alves; +Cc: Jean-Pierre Rosen

onsdagen den  7 mars 2001 13:09 skrev Mario Amado Alves:
> > > Have a look at my paper "In Defense of the Use Clause", available from
> > > http://www.adalog.fr/publica2.htm
> >
> > Should java be required to see the document?
>
> Of course. Dont you know we non-java-enabled-browser users are practically
> extinct ;-)
>
> /* Why dont we use java-enabled-browsers? Well, in my case, I cannot use
> Nestcape because it terminates abnormally and leaves my system in a bad
> shape. I cannot use IE because mine is a Linux box. So I must use Lynx and
> Amaya. */

I use Konqueror 2.1. It has support for java, but I haven't bothered to 
install a virtual machine or what it is called. I think that at least the 
name of the publication should have been clickable. That doesn't hurt. Then 
there can still be some applets just to show off.




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

* Re: Ada95 tutorials with sample code.
  2001-03-06 20:10       ` Erik Sigra
@ 2001-03-07 14:31         ` Simon Pilgrim
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Pilgrim @ 2001-03-07 14:31 UTC (permalink / raw)




Erik Sigra wrote:
> 
> tisdagen den  6 mars 2001 19:20 skrev Jean-Pierre Rosen:
> > "Sven Nilsson" <emwsvni@emw.ericsson.se> a �crit dans le message news:
> > 3AA48DE9.A0650F21@emw.ericsson.se...

> > Have a look at my paper "In Defense of the Use Clause", available from
> > http://www.adalog.fr/publica2.htm
> 
> Should java be required to see the document?

I have a Java enabled browser.  However, like many others behind a
firewall I can't "see" the applets because our firewall corrupts the
APPLET and OBJECT tags.

-- 
Regards,
Simon Pilgrim
BAE SYSTEMS, Rochester, UK



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

* Re: Ada95 tutorials with sample code.
  2001-03-07  7:54     ` Sven Nilsson
@ 2001-03-07 15:10       ` Marin David Condic
  2001-03-08  0:05       ` Mark Lundquist
  1 sibling, 0 replies; 32+ messages in thread
From: Marin David Condic @ 2001-03-07 15:10 UTC (permalink / raw)


Just an observation on a subject that has been beaten to death and run over
so many times that it is a greasy spot in the middle of the highway..... :-)

Many other languages give you a means of pulling in identifiers from other
"packages". Most older languages didn't give you any means of distinguishing
between an identifier from one context and one from another. Some newer
languages are providing things similar to Ada's context clauses so that
identifiers can be distinguished. (I'm particularly thinking of C++'s
namespaces and how you can now go SomeContext::SomeIdentifer) Its a great
feature to help sort out the numerous identifiers that exist in large
projects. We didn't always have it and we found ways of dealing with it in
older environments, so maybe some of those techniques apply here. At least
we can say that we have more options now than we did in other languages.

Ada's context features seem to me to be better than others I've seen because
they are very clear and unambiguous. (C++, for example, gets stuck having to
support most of the bad habbits that are exhibited in old C code) It is an
inherent part of the language that things exist within a context and they
have fully qualified names that let you find them.

The "use" clause can make things more or less readable, depending probably
more on the natural communicative gifts of the programmer writing the code.
Fortunately, modern development environments can provide considerable help
in finding an identifier if it wasn't fully qualified, so you kind of have
multiple options with plusses and minuses on all sides. There seem to be
three popular categories:

1) Never(with-possible-exceptions) use "use" so that you have fully
qualified names everywhere.

2) Use the "use" clause freely(with-possible-exceptions) so that
all(most/some) names appear to be what they are & rely on tools to help you
find them if you need to.

3) Use various renaming techniques to avoid the "use" clause yet provide
"short-form" qualified names so you get some of the best features of (1) and
(2) and avoid some of their pitfalls.

Since it seems to me that there are advantages and disadvantages for any of
these choices, its a sort of "Engineering Decision" with no clear "Right"
answer. Maybe the best thing to do is what projects ought to do about other
style issues (Capitalization, Indentation, Named-vs-Positional parameter
association, etc.....) Declare something to be the "Approved" approach and
be consistent in its usage. At least that way, programmers looking at the
code are going to know what to expect. I'm a big proponent of consistency
because I think it works well for speeding development and maintenance work.

Just my $0.02.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Sven Nilsson" <emwsvni@emw.ericsson.se> wrote in message
news:3AA5E92D.8446E7AB@emw.ericsson.se...
> Howdy
>
> I'm replying to my own entry here to try and recap some of the things
> thats been said. No flaming at all as far as I can see, thank you very
> much people!
>
> Most people seem to agree that the use-clause can be a dangerous thing,
> but there are voices raised in it's defence:
>
> 1. If you write/design your code properly, the use-clause won't be a
> problem and will make the program easier to read and maintain.
> 2. Standard things like Text_Io and Strings should be known to most
> Ada-users and in that case a use-clause can be used safely.
> 3. Using full names means the code will be less readable (this is noted
> in the paper "In defence of the use clause" available at
> http://www.adalog.fr/publica2.htm and is consistent with what I know of
> readablility index and such things (I'm a teacher at heart))
>
> All of these are good solid reasons to use "use", but I do not agree
> with them.
> The first one would be nice if it worked, but in my experience people
> don't think before they do. As I said in my last post, I work in big
> projects with a lot of people working on the same code in different
> teams, trusting that everyone has the same view of what is proper design
> is bordering on stupidity. "Trust is good, control is better" as the old
> saying goes.
> The second one should be very true indeed. My example in the other post
> (with TIO) is pretty stupid, really. BUT clever chaps tend to override
> standard things like text_io and strings to add little extra features.
> Like Ted I'm often called in to  figure out why things don't work and
> I've actually had a case where a badly implemented debug-text_io was the
> whole problem...
> The third statement is probably the hardest to argue with. Having spent
> the last three years reading and writing Ada-code using full names, I've
> gown pretty used to "filtering" out the prefixes until I need them, but
> as a beginner the code always seemed horrible complicated. That's a
> problem...
>
> Other notes that I feel should be pointed out again is
>
> 4. The option of "use type", which I agree can be VERY usefull on
> occasion.
> 5. Using "use" in the procedures/functions where it is really needed.
>
> Number 5 is perhaps the way to go. If we can keep our methods (to use a
> java term) short (as in K.I.S.S), this could become very readable AND
> traceable. I'll have to look into that one further.
>
> The last point I'd like to recap is concerning renaming. Some people
> obviously consider this to be the worst thing to befall mankind and
> about two years ago I would have agreed. Now, however, we've been using
> rename for so long and so extensively that we actually have "renaming
> conventions". Almost every file you open have a number of renames at the
> top, renaming standard packages that we use extensively. These renames
> are ALWAYS the same, which means that it actually becomes quite
> readable. So why didn't we name the packages that way to start with, you
> might ask. Simple. I know what TEPC is, but you don't. It really is a
> package name of some 30 characters (yes, that long) which I don't want
> to type and certainly don't want to read everytime it's used, but TEPC
> is ok to read and it tells me what I need to know. If you don't know
> what TEPC is, you just look it up in the rename section of the package.
> This works, but I agree that it's not a perfect world...
>
> So much for the recap. Thank you for all the comments, I'll ponder over
> them as I look over our naming conventions and coding principles.
>
> -Sven





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

* Re: Ada95 tutorials with sample code.
  2001-03-07 13:12 ` Erik Sigra
@ 2001-03-07 18:07   ` Jean-Pierre Rosen
  0 siblings, 0 replies; 32+ messages in thread
From: Jean-Pierre Rosen @ 2001-03-07 18:07 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 732 bytes --]


"Erik Sigra" <sigra@home.se> a �crit dans le message news: mailman.983970845.3271.comp.lang.ada@ada.eu.org...
> I use Konqueror 2.1. It has support for java, but I haven't bothered to
> install a virtual machine or what it is called. I think that at least the
> name of the publication should have been clickable. That doesn't hurt. Then
> there can still be some applets just to show off.
>
OK, OK. As I mentioned in a private reply, I took this as an opportunity to show some adapplets. I'll try to put something for the
non-java browsers when I get around to it.

--
---------------------------------------------------------
           J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://www.adalog.fr






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

* Re: Ada95 tutorials with sample code.
  2001-03-07  7:54     ` Sven Nilsson
  2001-03-07 15:10       ` Marin David Condic
@ 2001-03-08  0:05       ` Mark Lundquist
  1 sibling, 0 replies; 32+ messages in thread
From: Mark Lundquist @ 2001-03-08  0:05 UTC (permalink / raw)


Nice recap!

Sven Nilsson <emwsvni@emw.ericsson.se> wrote in message
news:3AA5E92D.8446E7AB@emw.ericsson.se...
> Howdy
>
> I'm replying to my own entry here to try and recap some of the things
> thats been said. No flaming at all as far as I can see, thank you very
> much people!

I think this one has been flamed over so many times, everybody is just
flamed out :-)

>
> Most people seem to agree that the use-clause can be a dangerous thing,

I would not call it "danger".  But I know what people mean who say that.

Ultimately, there is no right answer to this.  The reason is that what is
signal to me may be noise to you, and vice-versa.  That's the paradox of
understandability: there are many classes of "readers" of code (familiarity
level perhaps being the most important classification).

Some packages are clearly written with the idea that clients "use" them, as
evinced by the names chosen for declarations in the package (a classic
example would be something like Ada.Strings.Unbounded).  The idiom is that
the name of the abstraction gets built in to identifier names instead of
just being left in the package name, so you end up with
"To_Unbounded_String" instead of something like "Create".  I think the right
guideline is, when you reference a package like this, "use" it as it was
intended. The author wrote it in such a way that you should have no trouble
figuring out where things are declared (and when in doubt, you can still use
the qualfied name even though the package is on the "use" clause).  Adhering
to a "no use" rule for packages like this just seems silly.

That said, I generally prefer not to write packages in the "meant to be
use'd" style.  Which does not mean that I never "use" those packages!  I
often do (but as you and others pointed out, not necessarily in the global
use clause).

Mark Lundquist
Rational Software






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

* Re: Ada95 tutorials with sample code.
  2001-03-06 18:19       ` Robert A Duff
  2001-03-06 21:19         ` Ted Dennison
@ 2001-03-08  6:13         ` Simon Wright
  2001-03-10 16:30           ` Brian Rogoff
  1 sibling, 1 reply; 32+ messages in thread
From: Simon Wright @ 2001-03-08  6:13 UTC (permalink / raw)


Robert A Duff <bobduff@world.std.com> writes:

> Ted Dennison<dennison@telepath.com> writes:
> 
> > The common example used is Ada.Strings.Unbounded.To_Unbounded_String. Even I
> > have to admit this looks stupid. However, I'd claim that the stupidity is
> > entirely a result of stupid naming on the designers part. They quite easily
> > could have named the routine Ada.Strings.Unbounded.To, ...
> 
> Is this supposed to be an example of a name that works well both with
> and without use clauses?  Yikes.

This is an example of a name that was intended to work with 'use'. I
think that most of the Ada hierarchy is like that ..

> >...rather than repeating the
> > names of two parent packages in the subprogram's identifier.
> 
> I think it's repeating the name of a *type*, not packages.

Similarly, I've just done a Great renaming on the Booch Components
(http://www.pushface.org/components/bc/), replacing types like
BC.Containers.Collections.Unbounded.Unbounded_Collection by
BC.Containers.Collections.Unbounded.Collection (OK, these are generic
packages, so what's actually visible to the user has become something
more like My_Library_Unit.Collection rather than
My_Library_Unit.Unbounded_Collection). This was a change forced by
actually trying to _use_ my own work ..



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

* Re: Ada95 tutorials with sample code.
  2001-03-08  6:13         ` Simon Wright
@ 2001-03-10 16:30           ` Brian Rogoff
  0 siblings, 0 replies; 32+ messages in thread
From: Brian Rogoff @ 2001-03-10 16:30 UTC (permalink / raw)


On 8 Mar 2001, Simon Wright wrote:
> Robert A Duff <bobduff@world.std.com> writes:
> 
> > Ted Dennison<dennison@telepath.com> writes:
> > 
> > > The common example used is Ada.Strings.Unbounded.To_Unbounded_String. Even I
> > > have to admit this looks stupid. However, I'd claim that the stupidity is
> > > entirely a result of stupid naming on the designers part. They quite easily
> > > could have named the routine Ada.Strings.Unbounded.To, ...
> > 
> > Is this supposed to be an example of a name that works well both with
> > and without use clauses?  Yikes.
> 
> This is an example of a name that was intended to work with 'use'. I
> think that most of the Ada hierarchy is like that ..
> 
> > >...rather than repeating the
> > > names of two parent packages in the subprogram's identifier.
> > 
> > I think it's repeating the name of a *type*, not packages.
> 
> Similarly, I've just done a Great renaming on the Booch Components
> (http://www.pushface.org/components/bc/), replacing types like
> BC.Containers.Collections.Unbounded.Unbounded_Collection by
> BC.Containers.Collections.Unbounded.Collection (OK, these are generic

I'd go further and make it BC.Containers.Collections.Unbounded.T. Something like 
this style is used in Modula-3 libraries, and I've seen it in older Ada
libraries and in C. It has the great advantage that it should suit a "use
free" style (I'll refrain from the usual pejorative "use-phobe" :) and
carries less noise in such a style than the usual repeated long name. 

FWIW, I like use, but I generally write code in a use-free style. I detest
"use type", and think it is a hack on Ada to placate fanatics who claim
it's awful and then want to use it with operators and thus make operators
"special". Now the "with type" proposal is asymmetric, great. 

> My_Library_Unit.Unbounded_Collection). This was a change forced by
> actually trying to _use_ my own work ..

Very punny! Seriously, I agree that that'll get you to reevaluate options
quickly.

-- Brian





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

end of thread, other threads:[~2001-03-10 16:30 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-06 23:51 Ada95 tutorials with sample code Beard, Frank
     [not found] <Pine.LNX.4.10.10103071153320.971-100000@lexis.di.fct.unl.pt>
2001-03-07 13:12 ` Erik Sigra
2001-03-07 18:07   ` Jean-Pierre Rosen
     [not found] <01030621102401.00302@a77>
2001-03-07 12:09 ` Mario Amado Alves
  -- strict thread matches above, loose matches on Subject: below --
2001-03-06 23:58 Beard, Frank
2001-03-05 20:40 mcdoobie
2001-03-05 20:58 ` Erik Sigra
2001-03-06  2:45 ` Jeffrey Carter
2001-03-06  7:12   ` Sven Nilsson
2001-03-06  8:09     ` tmoran
2001-03-06 10:38     ` David C. Hoos, Sr.
2001-03-06 10:38     ` David C. Hoos, Sr.
2001-03-06 15:06       ` Ted Dennison
2001-03-06 15:29     ` Robert A Duff
2001-03-06 16:54       ` Ted Dennison
2001-03-06 15:48     ` Ted Dennison
2001-03-06 18:19       ` Robert A Duff
2001-03-06 21:19         ` Ted Dennison
2001-03-08  6:13         ` Simon Wright
2001-03-10 16:30           ` Brian Rogoff
2001-03-06 18:20     ` Jean-Pierre Rosen
2001-03-06 20:10       ` Erik Sigra
2001-03-07 14:31         ` Simon Pilgrim
2001-03-06 21:47       ` Ted Dennison
2001-03-07  0:11     ` Robert C. Leif, Ph.D.
2001-03-07  6:44     ` Jeffrey Carter
2001-03-07  7:54     ` Sven Nilsson
2001-03-07 15:10       ` Marin David Condic
2001-03-08  0:05       ` Mark Lundquist
2001-03-06 15:03   ` Marin David Condic
2001-03-06 14:31 ` BSCrawford
2001-03-06 22:38   ` mcdoobie

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