comp.lang.ada
 help / color / mirror / Atom feed
* Generic formals - meanings and Wikibook suggestion
@ 2008-04-07  9:25 Maciej Sobczak
  2008-04-07 10:08 ` christoph.grein
  2008-04-07 10:19 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 3+ messages in thread
From: Maciej Sobczak @ 2008-04-07  9:25 UTC (permalink / raw)


The following table:

http://en.wikibooks.org/wiki/Ada_Programming/Generics#Generic_formal_types

is extremely useful with generics and provides invaluable help when
writing or reading generic code.

(another way of putting it is that the syntax for generics is just
broken ;-) )

What is missing from this table is the full meaning of the basic:

type T is private;

This basic form is used in many places - even on the same Wikibook
page.

What is the exact meaning of this basic form? What knowledge about T
is expressed this way?
From AARM I conclude that it covers all non-limited types, but
Wikibook provides the same description (second row in the table) for:

type T (<>) is private;

Is there any difference between the two?

(hint: add the basic form to the same table in the Wikibook?)

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



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

* Re: Generic formals - meanings and Wikibook suggestion
  2008-04-07  9:25 Generic formals - meanings and Wikibook suggestion Maciej Sobczak
@ 2008-04-07 10:08 ` christoph.grein
  2008-04-07 10:19 ` Dmitry A. Kazakov
  1 sibling, 0 replies; 3+ messages in thread
From: christoph.grein @ 2008-04-07 10:08 UTC (permalink / raw)


type T is private;

Any definite non-private type, i.e. a type that allows assignment and
declaration of objects without initial expression.

type T (<>) is private;

Much like the above, but object declaration require an initial
expression because the type may be indefinite.

BTW: The table is incomplete for Ada 2005: interfaces are missing. I
think there should be separate tables for formal private and derived
types (definite and indefinite) lest the table become too confusing.



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

* Re: Generic formals - meanings and Wikibook suggestion
  2008-04-07  9:25 Generic formals - meanings and Wikibook suggestion Maciej Sobczak
  2008-04-07 10:08 ` christoph.grein
@ 2008-04-07 10:19 ` Dmitry A. Kazakov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry A. Kazakov @ 2008-04-07 10:19 UTC (permalink / raw)


On Mon, 7 Apr 2008 02:25:06 -0700 (PDT), Maciej Sobczak wrote:

> The following table:
> 
> http://en.wikibooks.org/wiki/Ada_Programming/Generics#Generic_formal_types
> 
> is extremely useful with generics and provides invaluable help when
> writing or reading generic code.
> 
> (another way of putting it is that the syntax for generics is just
> broken ;-) )

Broken syntax fits to a broken concept. (:-))

Formal generic types try to express the contract on the actual type. The
idea was to make the generic formal part resembling concrete type
declarations. The problem is that the former defines a set of types (class,
we would say now), rather than just one type. 

> What is missing from this table is the full meaning of the basic:
> 
> type T is private;
> 
> This basic form is used in many places - even on the same Wikibook
> page.
> 
> What is the exact meaning of this basic form? What knowledge about T
> is expressed this way?

That the contract of T includes (I don't care about wording in strictly Ada
terms):

1. Default constructor
2. Assignment / initialization
3. "=" and "/="
4. new
5. some attributes, I am too lazy to sort out

> From AARM I conclude that it covers all non-limited types, but
> Wikibook provides the same description (second row in the table) for:
> 
> type T (<>) is private;
> 
> Is there any difference between the two?

Yes, it drops the position 1, so the actual of T can be indefinite.

> (hint: add the basic form to the same table in the Wikibook?)

As well as other cases missing. For example formal access to subprogram:

type T is access function ...;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

end of thread, other threads:[~2008-04-07 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-07  9:25 Generic formals - meanings and Wikibook suggestion Maciej Sobczak
2008-04-07 10:08 ` christoph.grein
2008-04-07 10:19 ` Dmitry A. Kazakov

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