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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,96a1028e223610ff X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.germany.com!storethat.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Apostrophe question Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1178051815.717834.317520@n76g2000hsh.googlegroups.com> Date: Wed, 2 May 2007 12:24:47 +0200 Message-ID: NNTP-Posting-Date: 02 May 2007 12:24:47 CEST NNTP-Posting-Host: 415aa8b2.newsspool2.arcor-online.net X-Trace: DXC=k03JaUd=iKn>jlK2>IgHGdA9EHlD;3Ycb4Fo<]lROoRa8kFo5245;jDTKnd X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15460 Date: 2007-05-02T12:24:47+02:00 List-Id: On 1 May 2007 13:36:55 -0700, David Smith wrote: > I've read a number of Ada tutorials now, and I'm unclear on when the > apostrophe is required in certain spots. For example, why is it used > here: > > Father : Person_Access := new Person'(Father_First_Name, > Father_Last_Name); > > but not here: > > type Float_Array is array(Integer range <>) of Float; > type Float_Array_Access is access Float_Array; > V : Float_Array_Access := new Float_Array(1 .. 3); > > I'm sure there is a page about this somewhere, but I can't find it. > If someone could point me in the right direction, I'd appreciate it. You mean T(...) vs T'(...), where T is the name of a [sub]type? The former is either 1.a. Explicit type conversion Float (1 + 2) 1.b. [Sub]type specification Float_Array (1..3) here Float_Array (1..3) specifies a subtype of Float_Array constrained to the range 1..3. In the brackets you specify the constraint[s]. The latter is 2. Qualified expression. T specifies the expected [sub]type of what is in the brackets: Float'(1.0 + 2.0) You need it only if the compiler could not come out without your help. Or else when the language explicitly requires qualified expressions. In your case, the allocator new when allocates an initialized object requires the expression of be qualified (RM 4.8). I.e. new 1.0 -- illegal new Float'(1.0) -- That's OK This is why you have to say Person' before the aggregate of Person: (Father_First_Name, Father_Last_Name); [ Don't ask me why new does not eat plain expressions... (:-)) ] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de