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/20 Message-ID: #1/1 X-Deja-AN: 242761850 References: <3.0.32.19970423164855.00746db8@mail.4dcomm.com> <5kl9qc$g4d@bcrkh13.bnr.ca> <5kmek2$9re@bcrkh13.bnr.ca> <33727FA5.5C7A@sprintmail.com> <3374C19F.15FE@sprintmail.com> <3376CF85.3E15@sprintmail.com> <33828299.2A3@world.std.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-05-20T00:00:00+00:00 List-Id: In article <33828299.2A3@world.std.com>, brosgol@world.std.com wrote: >As Robert Dewar mentioned in an earlier article, the subject of "prefix >notation" for the OOP types, in particular Jean Ichbiah's proposal > class type T is ... end T; >did come up during the November 1992 WG9 meeting in Salem, Mass., but it >was defeated. >In any event, tagged types do share a number of properties with record >types (such as component selection, aggregate notation, provision for >discriminants), so using the "tagged record" syntax is not so strange. I'm not dogmatic about the "pure" object-oriented syntax, ie declare O : T; begin O.Op (A); end; though I do think it's pretty hip. What would be cool is to have a selector abstraction, to give you that for free, ie type Stack is ...; selector Top (S : Stack) return Item; So that I could do this: declare The_Stack : Stack; begin The_Item := The_Stack.Top; ... It would be cool to give the programmer control of selection, not unlike what C++ programmers get with references. What would be really cool is to have the compiler treat a selector "invokation" that same as if it were a reference to a record component. That way I could say The_Stack.Top := 5; instead of Update_Top (The_Stack, To => 5); The idea is to let the compiler do the automatic defereferencing (a selector "invokation" could be an lvalue or an rvalue): The_Stack.Top := The_Stack.Top + 1; It's always bothered me a bit (and Bertrand Meyer, too; read his book) that the syntax for selecting an unencapsulated (public) component has to be different from selecting an encapsulated one. The_Stack.Top vs. Top (The_Stack) Especially since we've sort of made this statement that tagged types are "really" records, it would be cool to take the analogy a step farther, by making component selection uniform. While we're at it, maybe we can throw in real constructors, too. We can solve the "problem" with limited types, by allowing a constructor to be called in the declarative region. That way limited types wouldn't have to be definate, or go on the heap unnecessarily. It seems that in Ada 83 design, selectors and constructors, known as "transfer functions," were treated literally as functions. But this confuses initialization (or "binding") with assignment, removing the programmer's ability to initialize a limited object properly (defined as "in the declarative region," or "during the object's elaboration"). -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271