From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d8c487e59f13ecdf X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-09 08:50:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!crtntx1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3DA45046.F5C66738@raytheon.com> From: Jerry Petrey <"jdpetrey"@raytheon.com> X-Mailer: Mozilla 4.79 [en]C-CCK-MCD CSC;Raytheon (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada Basics References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 09 Oct 2002 08:50:30 -0700 NNTP-Posting-Host: 147.24.93.55 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1034178631 147.24.93.55 (Wed, 09 Oct 2002 10:50:31 CDT) NNTP-Posting-Date: Wed, 09 Oct 2002 10:50:31 CDT Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:29619 Date: 2002-10-09T08:50:30-07:00 List-Id: 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 in email address to reply ---------------------------------------------------------------------------------