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 X-Received: by 2002:a24:f30f:: with SMTP id t15-v6mr3619362ith.22.1527370841771; Sat, 26 May 2018 14:40:41 -0700 (PDT) X-Received: by 2002:a9d:445c:: with SMTP id f28-v6mr709156otj.2.1527370841605; Sat, 26 May 2018 14:40:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!u74-v6no3591590itb.0!news-out.google.com!f20-v6ni3245itd.0!nntp.google.com!v8-v6no3613527itc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 26 May 2018 14:40:41 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=96.247.198.106; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 96.247.198.106 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2d717805-f6a4-4de9-bf4a-d45037034f96@googlegroups.com> Subject: Re: why "unconstrained subtype in component declaration" while said component given default value ? From: Jere Injection-Date: Sat, 26 May 2018 21:40:41 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:52705 Date: 2018-05-26T14:40:41-07:00 List-Id: On Saturday, May 26, 2018 at 5:03:23 PM UTC-4, Mehdi Saada wrote: > Hello. > Why is this case not allowed ? Is there really an implementation issue here ? I doubt so. Why should it be any different from the non-issue of initializing variables of unconstrained subtypes vs declaring uninitialized variables of constrained subtypes ? > type A (N: Positive) is record > II : Integer; > Chaine : String := Give_String(N); > end record; > Consider for a second that you are the compiler and you need to allocate a variable: My_Variable : A(10); What size (in bytes) do you need to allocate for the variable? Remember that the function Give_String can be exceedingly complex or even a function from a shared library. How do you at compile time determine the size of that record type? However you can do: type A(N : Positive) is record II : Integer; Chaine : String(1..N) := Get_String(N); end record; Because now the compiler will know at compile time how long the string is and thus how big to make the record.