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!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada202X: Easy to use "UML private"-like components Date: Sun, 23 Jun 2013 10:32:12 +0300 Organization: Tidorum Ltd Message-ID: References: <69246de0-4b33-4d47-b5be-a45e8c911fb0@googlegroups.com> <9qrbs8l828t3pvgves504a8fm7o1c7tcpj@4ax.com> <91qcs81k6am9l3u3n19lj0b072lc48td69@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net 6J0aeZoS46M48YEkHa9ubwdEfzBWm9sgiemjS2wqQo9JC9a7oK Cancel-Lock: sha1:0PMIDFRGfxIa0/oaf1SPTLJIn5w= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <91qcs81k6am9l3u3n19lj0b072lc48td69@4ax.com> Xref: news.eternal-september.org comp.lang.ada:15899 Date: 2013-06-23T10:32:12+03:00 List-Id: On 13-06-23 06:26 , Dennis Lee Bieber wrote: > On Sun, 23 Jun 2013 01:57:17 +0300, Niklas Holsti > declaimed the following: > >> >> Maybe my post was unclear: I tried to contradict Bob Duff's recollection >> that an opaque type in Modula-2 is more like an Ada private type than >> like an "stt access type". I think that a Modula-2 opaque type is very >> similar to an "stt access type". Do you agree with me? > > Having just refetched a few days of the thread to find out what "stt > access type" means, I can not comment on your assertion. The term was also unfamiliar to me, before Bob Duff's post. To make it clear, I think ( :-) ) we are discussing a structure of this form: package Pkg is type T is private; ... operations on T ... private type Object; -- Will be completed in the body of Pkg. type T is access Object; end Pkg; Here Pkg.T is the type used by the clients, and is the "stt access type", because it is an access to an incompletely declared type, Pkg.Object. The type Pkg.Object is completed in the package body: package body Pkg is type Object is ... whatever ... ... operation bodies ... end Pkg; 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. As far as I can see, the main difference between Ada and Modula-2 is that the Ada package declaration has to name the underlying type (Pkg.Object), because it has to declare Pkg.T as "access Object". That is not necessary in the Modula-2 definition module, because the opaque type declaration in Modula-2 implies that the type is a pointer. (As I understand it, Modula-2 has no other concept of "private type".) > So whatever these "stt access types" are, they are not something I've > encountered in my use of Python -- they sound a lot like a programming > convention for subverting what the compiler was designed to handle. They provide further separation of the declaration and implementation o the type, just as the Modula-2 opaque types do, and with the same drawbacks (see below). > Modula-2's opaque exports, OTOH, are the compiler's requirement for > handling data abstraction -- not something a programmer just uses in lieu > of some other paradigm. Because Modula-2 has no other way to privatize types. In Ada, the "private type" feature lets you hide the structure of a type from clients, yet reveal it fully in the package declaration, for the compiler's benefit. You can then decide whether or not to use an access type, i.e. an "stt access type" such as Pkg.T above. If you use an access type, you can defer the full declaration of the underlying type (and the necessary "with" clauses) to the package body, but this usually requires heap allocation of the objects. I tend to use "stt access types" when the type in question (e.g. Pkg.T) needs reference semantics and heap allocation anyway. (Being rather conservative in my programming style, I haven't yet leapt fully into controlled types.) -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .