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 autolearn=unavailable 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!xmission!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ada202X: Easy to use "UML private"-like components Date: Sun, 23 Jun 2013 09:12:53 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <69246de0-4b33-4d47-b5be-a45e8c911fb0@googlegroups.com> <9qrbs8l828t3pvgves504a8fm7o1c7tcpj@4ax.com> <91qcs81k6am9l3u3n19lj0b072lc48td69@4ax.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1371993174 11253 192.74.137.71 (23 Jun 2013 13:12:54 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 23 Jun 2013 13:12:54 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:9xLIuEPgKssqFIZ8VWmBmDSi/8U= Xref: news.eternal-september.org comp.lang.ada:15904 Date: 2013-06-23T09:12:53-04:00 List-Id: Niklas Holsti writes: > Pkg.T corresponds to a Modula-2 opaque type (or opaque eport, if you > prefer). Both the Ada compiler and the Modula-2 compiler know, based on > the package declaration or the definition module, that Pkg.T is a > pointer. Neither compiler knows anything about the type of the object to > which Pkg.T points, until the package body or implementation module is > compiled. The compilation model is that when compiling something, the compiler looks at information coming from the specs of imported things, but not their bodies. Modula-2 compilers actually work that way, and this is the reason for the must-be-pointer (or must be the same size as a pointer, or smaller, as I had (mis?)remembered it). It is also the reason for the private part kludge: the compiler sees the size of the full type for a private type (assuming it is known at compile time). But this reasoning makes no sense to me, because that's not how Ada compilers work. Any reasonable implementation of generics and inlining needs to look at bodies. So full types should be in bodies, and compilers should look there (at least in optimizing mode) to find out their size. On the other hand, the private part kludge wouldn't be so bad if the syntax were different: The private part should be a separate syntactic compilation_unit, with its own with clauses, and should normally be stored in a separate source file from the visible part. There's an awful lot of horrible code duplication caused by the fact that the private part is in the same file as the visible part. Separating it out into a different file would not prevent the compiler from looking at it! - Bob