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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,72c34c66b38e0e05 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-31 16:54:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Proposal: Constructors, Assignment [LONG] Date: Tue, 31 Dec 2002 18:54:50 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:32422 Date: 2002-12-31T18:54:50-06:00 List-Id: Dmitry A. Kazakov wrote in message ... >Randy Brukardt wrote: >> The basic idea is to somehow figure a value of Ada.Tags.Tag, then use it >> to control dispatching on a function that returns the correct kind of >> object. This requires a special call: >> >> Obj : T'Class := Func () use Tag_Value; > >The question is, will dispatching without an object be useful in cases other >than construction? Yes, I think so. Two other examples have come up: -- Calling the parent operation (which Ada does not have any convinient syntax for - currently you have to name the parent explicitly, which is a source of bugs); -- Handling "least common denominator" comparison. These aren't wildly compelling, admittedly. > This proposal requires new syntax. Mine > > Obj : T'Class (); > >requires only new attributes. Adding syntax to a modern compiler is cheap. Either its table driven or recursive descent; both are quite simple. OTOH, semantics still have to be implemented by hand. The concern about syntax comes from the cost of modifying other tools. If there is a way to avoid new syntax without changing the semantics much, then that is to be preferred. But if we're talking about implementing simple syntax and semantics compared to implementing complex semantics only, I'll take a simple syntax change any day. And your proposal comes under complex semantics, and would be very expensive to implement in Janus/Ada. Take your "only attributes" claim. In Janus/Ada (and probably other compilers), attributes are completely manually implemented. Every attribute is a bundle of special case code. It's especially expensive for attributes which can be specified. For instance, stream attributes (which these resemble) have dedicated components in type records which hold the current definition. Type records are initialized in a large variety of places in the compiler, and all of these would need to be updated (Ada 2005 will help that somewhat, but of course the compiler is implemented in Ada 95). So your "only new attributes" proposal would take many times more work to implement. Indeed, it would be impossible to implement without a wholesale restructuring of the compiler. Secondly, you are suggesting that somehow: Obj : T'Class (); is somehow the same as Obj : T'Class (); Essentially, you are saying that a discriminant constraint has the same semantics as a parameter list. But that clearly isn't true in the RM as written. The rules for these are defined in different places and are subtly different. Changing them to be the same would be very difficult without introducing dangerous incompatibilities. While that arguably might be better for new users, it could be a disaster for existing Ada users (and code). And it certainly would be a heck of a lot of work. >Though it is another question, I think that there is a need to have >something like user-defined anonymous access types, with the operations >becoming primitive for the pointed type. But it is probably far more >difficult than just constructors. Well, there is a proposal for "named anonymous access types" (AI-230). But the whole idea of a named anonymous type is an oxymoron, and that turns off a lot of people. And there are quite a few semantic problems with the proposal. So I wouldn't expect that proposal to be included in Ada 2005. Randy.