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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,73cb216d191f0fef X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.98.103 with SMTP id eh7mr971350wib.3.1363271127006; Thu, 14 Mar 2013 07:25:27 -0700 (PDT) Path: g1ni65494wig.0!nntp.google.com!goblin3!goblin.stu.neva.ru!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Thu, 14 Mar 2013 15:26:56 +0100 Organization: cbb software GmbH Message-ID: <18r2kop6fyozu.tctrjnghfxqs.dlg@40tude.net> References: <8klywqh2pf$.1f949flc1xeia.dlg@40tude.net> <513f6e2f$0$6572$9b4e6d93@newsspool3.arcor-online.net> <513faaf7$0$6626$9b4e6d93@newsspool2.arcor-online.net> <51408e81$0$6577$9b4e6d93@newsspool3.arcor-online.net> <1xqmd3386hvns.1og1uql2cgnuf$.dlg@40tude.net> <5140b812$0$6575$9b4e6d93@newsspool3.arcor-online.net> <5140f1ad$0$6634$9b4e6d93@newsspool2.arcor-online.net> <7jct0noryc1v.1rnj5kkzx6m35.dlg@40tude.net> <5141c499$0$6642$9b4e6d93@newsspool2.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2013-03-14T15:26:56+01:00 List-Id: On Thu, 14 Mar 2013 13:37:44 +0100, Georg Bauhaus wrote: >> How exactly Ada's Positive is not an abstract data type? > > Because ADTs are constructs of human mapping from a model space to the > space of language constructs. In this case the latter is defined in Ada > terms. That does not answer the question. ADT is a set of values and operations. Please, show how Positive is different from that. >> We don't talk about Positive'Base. We do about Positive. > > Positive'Succ does *not* declare parameters whose subtype is Positive. Surely it does. Proof: X : Positive := 1; Y : Positive := Positive'Succ (X); Either Ada is untyped or else Positive'Succ is effectively defined on Positive and returns Positive. > 22 S'Succ S'Succ denotes a function with the following specification: > > 23 function S'Succ(Arg : S'Base) > return S'Base > > We don't talk about Positive'Base, you say? Yes, since the language allows usage Positive with Positive'Succ that automatically means that Positive has this operation. >>> subtype V is Integer range -2 .. +34; >>> >>> does not declare a new type (LRM 3.2.2(1)). >> >> Nevertheless >> >> Positive'Base /= Positive >> >> and both are types. > > The second claim is not true in Ada as relevant to this discussion, > because Positive's subtype constraint does not introduce a type. Any set of values and operations introduces an abstract data type per definition of. Compare: C++ reference manual uses the term "class" for what is ADT. That does not make C++ classes non-types. They still are. >>>> It is not a problem of definitions. >>> >>> Is it *solely* a problem of definitions from the non-Ada world. >> >> So, it is prime numbers which are broken. Good to know... > > Prime numbers are not defined in Ada, so the definition of Ada cannot > break them. The subtype named Prime that was given was essentially a > constraining predicate. If anyone thinks that 'Succ can be > re-interpreted to refer to a non-interval subset of integral numbers > of an Ada type, and it can't, then that's the problem: A plausible > assumption about the definition vs the actual definition. That is a language problem. Dynamic predicates will be seen, felt and used as abstract data types. This is why they should not be there. They effectively make the language typing weaker. And they are against the core Ada design idea that any implicit choice must be safe and any unsafe choice explicit. Inheritance of 'Succ is unsafe for certain types of constraints. > There are two problems instead: > > 1) to think that a subtype creates a type It certainly does. Positive /= Integer and the inequality here is in Ada terms. > 2) to assume that 'Succ is not what it is Exactly, ARM assumed something about programmer's intentions regarding the subtype Prime and failed miserably. So did PL/1 with its ad-hoc type conversions. Ada designers knew all that in 80's. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de