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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c469fdacc2f3302b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!news.mixmin.net!news2.arglkargh.de!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Dynamic Variant Record Creation Date: Wed, 17 Mar 2010 19:02:36 -0500 Organization: Jacob Sparre Andersen Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1268870557 29254 69.95.181.76 (18 Mar 2010 00:02:37 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 18 Mar 2010 00:02:37 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news2.google.com comp.lang.ada:10611 Date: 2010-03-17T19:02:36-05:00 List-Id: "Robert A Duff" wrote in message news:wccr5nj247r.fsf@shell01.TheWorld.com... > "Randy Brukardt" 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.