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,FREEMAIL_FROM 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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Type invariants and private extensions? Date: Thu, 14 Sep 2017 16:58:13 +0300 Organization: Aioe.org NNTP Server Message-ID: References: <364ff8e0-c7dd-4980-b19f-5d438edd8353@googlegroups.com> <7df81b3c-1fde-4395-8b9b-1a945820a7f7@googlegroups.com> <45fe84b9-3fea-44e9-ab87-c91370a0cd2e@googlegroups.com> NNTP-Posting-Host: qUTqmJlZKcITHxg9FVl9Fw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:48133 Date: 2017-09-14T16:58:13+03:00 List-Id: Victor Porton wrote: > Shark8 wrote: > >> On Tuesday, September 12, 2017 at 4:59:17 PM UTC-6, Victor Porton wrote: >>> >>> Thanks. >>> >>> But this seems not to solve my problem: >>> >>> The base type for Example cannot be defined as a discriminated type for >>> certain Type_Enumeration, because it is possible that when creating the >>> object it may be yet unknown what the value of the discriminant should >>> have (my main problem is to invent somethings if this value is known at >>> object creation, but we must support the unknown case too). AFAIK, it is >>> not possible to change the discriminant later. >> >> What are you doing that you need to create an object w/o knowing the >> types? I've used the variant-record approach in several interpreters to >> excellent effect; I've also used tagged-type hierarchies, too. > > Consider an interactive user interface. > > The user enters the query command. > > After this I create the object (at this point its "kind" is not yet > known). After this I parse the query with the object. At this point I can > determine the kind of the object (which depends on the query text), but at > this point the object already exists, so that I cannot assign the > discriminant. On the other hand, when it is done programmatically without a user intervention, the kind of object is usually known at the point of object creation. In this case I could use the discriminant approach. But this breaks the above case with a query entered interactively by a user. -- Victor Porton - http://portonvictor.org