TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Samuel Mize <[log in to unmask]>
Reply To:
Samuel Mize <[log in to unmask]>
Mon, 16 Nov 1998 16:13:05 -0600
text/plain (72 lines)
David Botton wrote:
> I tend to like the idea that the syntax of the language is loose and
> allows me to use the form that works best for the individual class /
> package.

I agree, however see below.

> ---Nasser Abbasi <[log in to unmask]> wrote:
> >
> > At Sun, 15 Nov 1998 17:36:29 +0100
> > >
> >
> > it is more than just "synatx".
> >
> Only if you are sloppy about your coding policy.
> Again, only if you are sloppy.
> Unless you are sloppy, you lay things out to please the reader. Of
> course when you need to, you can deviate, unlike other languages.

You could make the same arguments about enumeration types.  If you are
not sloppy about your coding policy, why not just use integer codes?

The answer is twofold: there are additional semantics attached to
enumerations, and the compiler uses these to detect coding errors.

The same arguments can be advanced for a "class" container.  A
properly-defined "class" is more than just a package that contains,
among its other baggage, a tagged type.

In fact, this distinction isn't really drawn in C++, as I understand
it -- the "class" there is also used as a general packaging construct.

It would be valuable to have a "class" type of package, whose spec:

- must define exactly one tagged type

- must contain only "methods" of that tagged type: its potentially
  dispatching subprograms, and subprograms with parameters that are
  of that type's 'class

- must not contain any *other* subprograms

This would be a pure class.  It would be, in effect, a strongly-typed
package.  It would provide a stronger definition of "class" than C++
has.  People who are doing pure object-oriented development may find
it quite useful to prevent accidentally defining a "diluted" class.

A compiler vendor could add a pragma "class" that would tell the
compiler the enclosing package is intended to be a class, and it
should fail if it doesn't meet those specs.  If this became popular,
it could be considered for addition to the next rev of Ada.

Perhaps a "class" package would also require that all the subprograms
in the package have the controlling operand as the first parameter
(the return value, for functions).  This would help out the people who
find the syntax "object.message" to be more readable.

Is this something that could be done with ASIS -- the compiler would
ignore the pragma, I guess, but could you have an ASIS tool that
detects it and warns you if your code has bad class packages?

Sam Mize

Samuel Mize -- [log in to unmask] (home email) -- Team Ada
Fight Spam: see \\\ Smert Spamonam