From: Victor Porton <porton@narod.ru>
Subject: Re: Type invariants and private extensions?
Date: Thu, 14 Sep 2017 16:58:13 +0300
Date: 2017-09-14T16:58:13+03:00 [thread overview]
Message-ID: <ope1tu$1e2f$1@gioia.aioe.org> (raw)
In-Reply-To: ope1qn$1dud$1@gioia.aioe.org
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
next prev parent reply other threads:[~2017-09-14 13:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 19:51 Type invariants and private extensions? Victor Porton
2017-09-11 20:00 ` Egil H H
2017-09-11 20:48 ` Victor Porton
2017-09-11 21:19 ` Egil H H
2017-09-11 21:27 ` Victor Porton
2017-09-11 21:49 ` Egil H H
2017-09-11 22:00 ` Victor Porton
2017-09-11 22:06 ` Egil H H
2017-09-12 7:30 ` Dmitry A. Kazakov
2017-09-11 22:00 ` Jere
2017-09-11 22:02 ` Victor Porton
2017-09-12 18:26 ` Jeffrey R. Carter
2017-09-12 18:54 ` Victor Porton
2017-09-12 19:56 ` Jeffrey R. Carter
2017-09-12 20:08 ` Victor Porton
2017-09-12 22:34 ` Shark8
2017-09-12 22:59 ` Victor Porton
2017-09-13 4:21 ` Jere
2017-09-13 4:28 ` Jere
2017-09-13 4:34 ` Jere
2017-09-14 13:52 ` Victor Porton
2017-09-15 0:48 ` Jere
2017-09-16 14:22 ` Victor Porton
2017-09-14 7:28 ` Shark8
2017-09-14 13:56 ` Victor Porton
2017-09-14 13:58 ` Victor Porton [this message]
2017-09-11 22:48 ` Shark8
2017-10-02 23:16 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox