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!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: operation can be dispatching in only one type Date: Tue, 24 Nov 2015 10:09:09 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <04eb6626-644b-4b16-a329-c35659a9fbe2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 24 Nov 2015 17:06:50 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="caa759af2a9c666aec02942f6fe5abd6"; logging-data="21312"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Hdy9b48N0VNkf8m+OHx0y92F6MMkix/8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <04eb6626-644b-4b16-a329-c35659a9fbe2@googlegroups.com> Cancel-Lock: sha1:AneUsPmQoeuE+ldBV7RE3P6W+Fs= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:28523 Date: 2015-11-24T10:09:09-07:00 List-Id: On 11/24/2015 02:08 AM, Serge Robyns wrote: > > I didn't know about the position, I honestly believed it had to be the 1st. I don't know where I read that. Anyway I'm reading now the A-LRM 2012. I'm using "Self" as a naming convention. Dispatching is described in ARM 3.9.2(2/3). Note that a function call can dispatch on its result type. > I though that packaging and typing were quite independent and hence this is why I merged these two types in one package as they form a coherent assembly. I also recall some "advertisement" about that "fact". But it seems not to be that fully true. What is called a "class" in most languages (other than Ada) involves a type declaration (a set of values and a set of operations on those values), encapsulation of the value and its operations, and information hiding of the implementation of the values. In Ada, the pkg provides encapsulation and information hiding, independent of the mechanisms for declaring types. To get the equivalent of a "class" in Ada one must put the type and operation declarations into a pkg. Pkgs, unlike "classes", are intended to be used for other things as well. Note that the Ada construct that most closely matches a "class" is a protected type. > Like for example creating new specialized versions of the T_Account and per the rules you can only write "type New_T is new Old_T" for tagged types. I'm not sure what you're saying here, but one can derive a new type from any type, not just tagged types. This existed in Ada 83: type George is new Integer [range Low .. High]; The Ada-95 designers built on that to provide type extension: type George is new Martha with record ... The only thing you *need* tagged types for in Ada is finalization. They also provide Object.Operation notation, which is nice, and many types are declared tagged solely to provide that (the containers are examples of this). Type extension, combined with a container, also provides a kind of syntactic noise that allows self-referential types without access types/values. Other than those uses, with adequate thought before beginning coding, one can implement anything more clearly without tagged types than with. -- Jeff Carter "Whatever it is, I'm against it." Horse Feathers 46