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: Tue, 24 Jan 2017 15:26:13 +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:33142 Date: 2017-01-24T15:26:13+01:00 List-Id: On 24/01/2017 14:58, Victor Porton wrote: > It seems that you didn't understood me. You should have asked about data definition layer, not type then. Types have operations. > All I ask is just an Ada type which would be so flexible that could store > any kind of a value (just like as a variable in a dynamic language). Task value, protected object value, a value from generic instance not yet instantiated, subprogram value? In languages you have in mind there are types which can be used that way and not-so-much-types which cannot. > This type could be a variant record which could store numbers, lists/arrays, > strings, etc. (anything that can be stored in a variable in a dynamic > language). Then you should have asked about a variant type of some predefined set of scalar types and predefined class of containers. It has little use in Ada. As an implementation consider stream attributes. For a stream take a memory-located stream. Yes it is implemented in Ada. It has almost no use because Ada lacks things I listed. You cannot hang an interface on a stream object in order to access the object stored in the stream in the same way the original type is accessed (AKA dynamic cast, AKA polymorphic object). For this the stream object must inherit the interface of the type it contains, and do that ad-hoc. Variant record types do the job (dynamic cast is performed by variant selection per discriminant), but they are very very limited in what they can do. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de