comp.lang.ada
 help / color / mirror / Atom feed
* strong typing
@ 1990-01-05  1:28 Mark Gerhardt
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Gerhardt @ 1990-01-05  1:28 UTC (permalink / raw)



                       Subject:                                Time: 5:27 pm 
  OFFICE MEMO          strong typing                           Date: 1/4/90
In response to Ed Berard's request for strong typing references, here is a
constructive example in this usually ornery-for-its-own-sake discussion, Look at
TRELLIS done by Digital.  It makes good arguments as to how to combine classes,
etc with strong typing.

Some people want solutions, others just want to complain.  More constructive
data and less rhetoric is still welcome here.

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

* strong typing
@ 1996-10-08  0:00 AGBOH CHARLES
  1996-10-10  0:00 ` Norman H. Cohen
  0 siblings, 1 reply; 3+ messages in thread
From: AGBOH CHARLES @ 1996-10-08  0:00 UTC (permalink / raw)



Hi 

Ada's strong typing mechanism doest not allow identifiers of different
types to assigned to each other.  Why are subtypes and parent type 
permitted. Why can derived types and parent types be assigned to each other.
Apparently a derived type and sybtypes are new types so assignment should not 
be possible.







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

* Re: strong typing
  1996-10-08  0:00 strong typing AGBOH CHARLES
@ 1996-10-10  0:00 ` Norman H. Cohen
  0 siblings, 0 replies; 3+ messages in thread
From: Norman H. Cohen @ 1996-10-10  0:00 UTC (permalink / raw)



AGBOH CHARLES wrote:

> Ada's strong typing mechanism doest not allow identifiers of different
> types to assigned to each other.  Why are subtypes and parent type
> permitted. Why can derived types and parent types be assigned to each other.
> Apparently a derived type and sybtypes are new types so assignment should not
> be possible.

A subtype is NOT a distinct type, but simply a subset of its type. Given
the declaration

   X: Character := 'N';

the current value of X belongs to type Character, to the subtype
Character range 'A' .. 'Z', to the subtype Character range 'G' .. 'R',
etc.  Indeed, Character itself is a subtype, consisting of every value
of the type.  A declaration such as

   subtype ST is Character range 'A' .. 'F';

simply establishes ST as a shorthand for Character range 'A' .. 'F'. 
(In some places, such as parameter specifications, the syntax of Ada
only allows subtype names, so this shorthand is sometimes vital.)

In contrast, a derived type IS a new, distinct type, and assignment
between a derived type and it parent type is NOT allowed.  However, a
value of a derived type can be CONVERTED to a value of its parent type,
and the converted value can be assigned.  (Conversion in the other
direction is also possible when the types are not tagged.)

Shameless commercial :-) :  For a fuller discussion, see Chapter 4 of
Ada as a Second Language.  The chapter is devoted to these issues.

-- 
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen




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

end of thread, other threads:[~1996-10-10  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-08  0:00 strong typing AGBOH CHARLES
1996-10-10  0:00 ` Norman H. Cohen
  -- strict thread matches above, loose matches on Subject: below --
1990-01-05  1:28 Mark Gerhardt

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