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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Seeking for papers about tagged types vs access to subprograms Date: Fri, 3 May 2013 08:49:05 +0200 Organization: cbb software GmbH Message-ID: References: <1d73jn954z90t.ze60axadntyr$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 15waz9CoS+eMakbyhTPyFQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:15310 Date: 2013-05-03T08:49:05+02:00 List-Id: On Thu, 2 May 2013 16:49:18 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:1d73jn954z90t.ze60axadntyr$.dlg@40tude.net... >> On Wed, 1 May 2013 20:09:46 -0500, Randy Brukardt wrote: > ... >>> Nitpick: "new" is not an operator, it is an *operation*, things whose >>> behavior cannot be modified directly. Like membership, it would be hard to >>> make "new" an operator because one of the arguments can be a type (rather >>> than an object or value), and it's hard to see how that could be mapped to >>> an Ada function. (Adding type parameters seems over the top.) >> >> type Root_Access_Type is interface ...; >> function "new" return Root_Access_Type is abstract; >> >> If access types were "untagged" class, "new" would be a plain primitive >> operation. > > You're missing something here, and that's the information about the > designated type/object. If you have: > > Ptr := new Piece (Color => Black); > > that information about the discriminant has to be transmitted somehow as it > can controls the size of the allocated object. Yes, but my response was to your point about the object's type. You don't need explicit types with primitive operations, provided, the result is properly typed. In all cases where Ada 83 used [sub]type specification: T'Image (X) new T (X) T (X) etc, this was because of lack of typing. Regarding discriminants, this is not a problem, because the signature of the predefined "new" would be generated by the compiler, which could include necessary parameters as it does now. BTW, for constructors and allocators, there could a [sub]type attribute T'Constraints which would yield a null record type with the discriminants of T. E.g. let type Foo (X : Integer; Y : Boolean) is record I : Integer end record; then Foo'Constraints is type Foo'Constraints (X : Integer; Y : Boolean) is null record; This type + a mechanism to flatten tuples would give the signature you wanted for "new" without compiler magic. > Similar thoughts apply to memberships like "obj in T'Class". One might be > able to write a function to implement that, but you'd have to pass tags to > do so, which would bear no resemblance to normal subprogram call (it would > be much more like the relationship of a storage pool to an allocator). To me X in T and X in T'Class are syntax sugar for operations on tags: X in T <=> X'Tag = T'Tag X in T'Class <=> X'Tag <= T'Tag (tree order) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de