comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry Petrey <"jdpetrey<NOSPAM>"@raytheon.com>
Subject: Re: Ada Basics
Date: Wed, 09 Oct 2002 08:50:30 -0700
Date: 2002-10-09T08:50:30-07:00	[thread overview]
Message-ID: <3DA45046.F5C66738@raytheon.com> (raw)
In-Reply-To: d40d7104.0210090453.f6aed66@posting.google.com



prashna wrote:

> Hi all,
> What is the difference between declaring a type by using new (ex type
> one_to_hundred is new Integer range 1..100) and declaring a type
> without using new (type one_to_hundred is range 1..100)?
>
> Thanks in advance

The 'new' creates an explicit derived type which is a copy of the parent type
and inherits the primitive operations of the parent and any user defined
operations
of the parent before the derived type is defined.  It is a distinct type and
would
require a type conversion to be mixed with objects of the parent type, for
example.

In the example you cited, there would be little difference since all integer
types
are derived types - type one_to_hundred is range 1..100 creates a derived
type but the compiler chooses which predefined integer type to derive from (it
might for
example, choose short_integer).
With  one_to_hundred is new Integer range 1..100 , you are explicitly choosing

the parent type to be the predefined type Integer.

In Ada 95, derived types form the foundation of the polymorphic type
mechanism.
I would suggest you look at one of the good tutorials for more details on this

subject.  Look at http://www.adapower.org/ at the tutorials section.

Jerry
--
---------------------------------------------------------------------------------

-- Jerry Petrey
-- Senior Principal Systems Engineer - Navigation (GPS/INS), Guidance, &
Control
-- Raytheon Missile Systems          - Member Team Ada & Team Forth
-- NOTE: please remove <NOSPAM> in email address to reply
---------------------------------------------------------------------------------






  parent reply	other threads:[~2002-10-09 15:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-09 12:53 Ada Basics prashna
2002-10-09 15:27 ` Georg Bauhaus
2002-10-09 15:50 ` Jerry Petrey [this message]
2002-10-09 17:44   ` Wes Groleau
2002-10-09 18:37 ` Matthew Heaney
2002-10-09 18:58   ` David C. Hoos
2002-10-09 19:09     ` Matthew Heaney
2002-10-09 20:05 ` Robert A Duff
2002-10-10 10:47 ` prashna
replies disabled

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