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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Experimenting with the OOP features in Ada Date: Tue, 3 Jan 2017 21:42:40 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <29380aa7-0c3b-4908-94c6-aa91f3996b42@googlegroups.com> NNTP-Posting-Host: s3c6wwRqkurrfTZpuYYZ+w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:33027 Date: 2017-01-03T21:42:40+01:00 List-Id: On 2017-01-03 18:07, G.B. wrote: > On 03/01/2017 15:31, Dmitry A. Kazakov wrote: >> On 2017-01-03 14:57, Laurent wrote: > >>> Item.Name.Set (Name=>"Something") looks better than >>> >>> Item.Name := My_Strings.Handle.Create (Value => Name); >> >> Some people like using unary "+" for this. E.g. >> >> function "+" (Value : String) return My_Safe_String >> renames My_Strings.Handle.Create; >> >> Then you can do: >> >> Item.Name := +"Something"; > > Using an operator seems always a good idea when the language > does not otherwise support a ubiquitous notion such as a handle. Nope, the good idea is to fix the language. > Otherwise, both the domain data types and data handling > types are indistinguishable, language-wise, and the reader > is left in daze: is this program text about handles or is > it about data? No problem. When you write 1 is it Positive, Integer, mod 4? The reader easily determines that from the context as the compiler does. In rare cases when it cannot be determined, a qualified expression does the job. Ada should have supported subtypes we discussed before. The ones that do not share the representation but only the interface. Then both String and a handle to a String could be subtypes of each other and you could assign one to another (which would invoke a user-defined conversion). That would also resolve the mess of standard Ada string types. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de