comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Dynamic Variant Record Creation
Date: Wed, 17 Mar 2010 19:02:36 -0500
Date: 2010-03-17T19:02:36-05:00	[thread overview]
Message-ID: <hnrqit$si6$1@munin.nbi.dk> (raw)
In-Reply-To: wccr5nj247r.fsf@shell01.TheWorld.com

"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message 
news:wccr5nj247r.fsf@shell01.TheWorld.com...
> "Randy Brukardt" <randy@rrsoftware.com> writes:
...
>> I'd like to see a solution to this problem, but I don't think this is it.
>> The problem is that the compiler wouldn't know what components to 
>> generate,
>> so it would effectively have to generate a giant case statement:
>>
>> X := (Token => T, others => <>) would become:
>>
>> case T is
>>    when LEX_ID => X := (Token => LEX_ID, String_Id => <>);
>>    when '!' => X := (Token => '!');
>>    ...
>> end case;
>
> Well, this is not hugely different from the case statement that the
> compiler has to generate for:
>
>    X : Token_Unit (Token => T);
>
> to default-initialize stuff.

Well, for Janus/Ada at least, that giant case statement is generated exactly 
once, in the unit containing the type, to create an initialization "thunk". 
We don't keep enough information to do it efficiently later.

Note that the example given is exactly the same as default initialization, 
so that wouldn't be a problem, but if there are additional components 
specified, the default initializer couldn't be used. (It would be incorrect 
to call functions used by the default initial values of components that have 
explicit values. The ACATS [mostly the Ada 83 version] checks for stuff like 
that.)

                            Randy.





  parent reply	other threads:[~2010-03-18  0:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16 17:11 Dynamic Variant Record Creation Warren
2010-03-16 18:31 ` Georg Bauhaus
2010-03-16 18:57 ` Adam Beneschan
2010-03-16 20:01   ` Warren
2010-03-16 20:09     ` Jeffrey R. Carter
2010-03-16 20:24       ` Warren
2010-03-16 20:40         ` Robert A Duff
2010-03-16 20:44           ` Warren
2010-03-16 20:31     ` Robert A Duff
2010-03-16 20:59       ` Warren
2010-03-16 21:55         ` Jeffrey R. Carter
2010-03-17 14:40           ` Warren
2010-03-18 12:57           ` Warren
2010-03-16 21:58         ` Robert A Duff
2010-03-17 14:22           ` Charmed Snark
2010-03-17 14:49             ` Robert A Duff
2010-03-17 16:30               ` Warren
2010-03-16 21:15       ` Adam Beneschan
2010-03-16 23:24       ` Adam Beneschan
2010-03-16 20:15   ` Robert A Duff
2010-03-16 21:00     ` Warren
2010-03-16 23:39   ` Randy Brukardt
2010-03-16 23:43     ` Randy Brukardt
2010-03-17  0:15     ` Robert A Duff
2010-03-17 14:28       ` Warren
2010-03-18  0:02       ` Randy Brukardt [this message]
2010-03-17  4:20     ` Adam Beneschan
2010-03-18  0:13       ` Randy Brukardt
2010-03-18 13:00         ` Warren
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox