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: Dynamic type system for Ada Date: Wed, 25 Jan 2017 09:23:24 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; 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:33153 Date: 2017-01-25T09:23:24+01:00 List-Id: On 24/01/2017 22:21, Randy Brukardt wrote: > I do wonder how useful such a hierarchy would be, but I suppose someone > would have to build it to find out. Not much. I did exactly this before. The problem is that you get the "god-class" in the end. In order to be able to re-interpret the value as a given scalar type you have to add a primitive operation to the abstract base. E.g. function As_Unsigned_32 (Value : Abstract_Variable) return Unsigned_32 is abstract; -- Raises Type_Error if not of the type And so for each scalar type. And for arrays and records. Otherwise you have to explicitly convert (upcast) to specific instance derived from Abstract_Variable which is much worse. P.S. I intended to use that on top of a stream exchange, but the interface is so heavy that it adds no advantage to direct reading the target object from the stream. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de