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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.87.225 with SMTP id bb1mr10529219obb.16.1393283548968; Mon, 24 Feb 2014 15:12:28 -0800 (PST) X-Received: by 10.182.199.39 with SMTP id jh7mr39716obc.25.1393283548791; Mon, 24 Feb 2014 15:12:28 -0800 (PST) Path: border1.nntp.ams2.giganews.com!backlog3.nntp.ams3.giganews.com!backlog3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.erje.net!us.feeder.erje.net!news.glorb.com!uq10no1100405igb.0!news-out.google.com!h8ni97igy.0!nntp.google.com!uq10no1100392igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 24 Feb 2014 15:12:28 -0800 (PST) In-Reply-To: <90153ba2-ffe8-4696-8459-d81a0f703c9e@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=97.123.201.137; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 97.123.201.137 References: <90153ba2-ffe8-4696-8459-d81a0f703c9e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Why no abstract non-tagged types? From: Shark8 Injection-Date: Mon, 24 Feb 2014 23:12:28 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Original-Bytes: 2707 Xref: number.nntp.dca.giganews.com comp.lang.ada:185071 Date: 2014-02-24T15:12:28-08:00 List-Id: On Thursday, February 20, 2014 8:04:08 PM UTC-7, Britt wrote: > Recently I've been wishing I could declare some otherwise conventional enumeration types as "abstract" so they could only be used as a template for derived types. > > Such abstract types couldn't be used directly for object declarations. For example: > > type Valve_State_Base_Type is abstract (Unknown, Open, Closed); -- in Ada 202X > > Valve_State : Valve_State_Base_Type; -- illegal, type is abstract You already have this ability in Ada... in fact you've had it since Ada 83: Generic Package Abstract_Enumeration is Type Enumeration is (Value_1, Value_2, Value_3, Value_4, Value_5); End Abstract_Enumeration; If you WITH Abstract_Enumeration you cannot directly use Abstract_Enumeration.Enumeration, you need to instantiate it first: Package Enums is new Abstract_Enumeration; Package Other_Enums is new Abstract_Enumeration; Defines two instances of Enumeration, one fore Enums and another for Other_Enums, although they have the same names they are incompatible w/o type-casting. ----- [More recent Ada-specs] If you wanted something like subtypes, you could have a generic something like: Generic with Package AE is new Abstract_Enumeration(<>); First : AE.Enumeration := AE.Enumeration'First; Last : AE.Enumeration := AE.Enumeration'Last; Package Enumeration_Subtype is Subtype Enumeration_Subtype is AE.Enumeration range First..Last; End Enumeration_Subtype;