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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Strings with discriminated records Date: Sun, 27 May 2018 14:40:52 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <55ce14eb-6b83-4ea0-a550-f9e1410d0b06@googlegroups.com> <704ab1a8-c954-460e-81e7-05c64fcfaba4@googlegroups.com> <3080a617-08ee-47f6-9f07-5207e4406508@googlegroups.com> NNTP-Posting-Host: CvkHMVp693S8Z+lk11jyqg.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:52.0) Gecko/20100101 Thunderbird/52.8.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader02.eternal-september.org comp.lang.ada:52723 Date: 2018-05-27T14:40:52+02:00 List-Id: On 2018-05-27 14:22, Mehdi Saada wrote: > What do you mean by "no constructor" exactly ? You said that several times, but never stated your point precisely (or I missed it). Constructor is a sequence of actions that makes a valid object of type T from a chunk of raw memory. Constructor cannot be a procedure or a function, but it can call user-defined hooks from it. Ada compiler generates constructors where necessary, but offers little (controlled types) or no support for user-defined hooks. > What's the problem with constructor functions ? They do not work well with limited types and inheritance trees especially in presence of private types and private extensions. Another aspect is lack of type safety. It is easy to circumvent or misuse constructing functions leaving the object in an undefined state, yet considered valid = typing violation. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de