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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d1df6bc3799debed X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Syntax for tagged record types (was Re: Not intended for use in medical,) Date: 1997/05/24 Message-ID: #1/1 X-Deja-AN: 243691664 References: <3.0.32.19970423164855.00746db8@mail.4dcomm.com> <33867D87.21BA@sprintmail.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-05-24T00:00:00+00:00 List-Id: In article , bobduff@world.std.com (Robert A Duff) wrote: >This sort of thing could make sense for limited types, too -- as others >have pointed out, Ada *confuses* initialization and assignment. >However, it seems tricky to implement: > > type T is limited > record [snip] > > function G return T is > begin > ... > return F; > ... > end G; > > X: T := G; -- Not Ada. > >If the above were legal, the compiler would need to allocate the >deeply-nested Result object in a non-nested place (on the heap?), since >it would "become" the object X. No fair copying Result into X, since >the type is limited. The seems a bit tricky, especially in the case >where the functions return something whose size is unknown at the point >of the call. Which is part of the reason I'm advocating a different abstraction - a constructor abstraction rather than a function (which is an expression abstraction). With a constructor abstraction, we are free to impose whatever restrictions are necessary to make construction work. The statement X : T := G; would remain illegal, assuming G is a function. If the representation of T contains a limited component, then perhaps the rule could be that T has to be definate (so we can avoid an illegal copy?). Maybe not: we just need some way of allocating the object on the stack, and letting the constructor manipulate that object, so that no copying is ever required. It would be really swell too, if in the constructor we were able to invoke the constructors for the object's components. An important goal, though, is for constructors for limited types that are indefinate. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271