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: 2003-01-02 11:36:24 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: Thu, 2 Jan 2003 13:36:56 -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:32457 Date: 2003-01-02T13:36:56-06:00 List-Id: Dmitry A. Kazakov wrote in message ... >Randy Brukardt wrote: >> 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? > >Why this sort of syntax was chosen? I chose it only because it has a natural, cheap, and obvious implementation. I was hoping someone would have a better suggestion (but that turned out to be "kill the idea"). >I think more consequently in Ada's >spirit would be sort of: > > Obj : T'Class (Tag_Value) := Func (); > >Isn't tag a natural constraint/discriminant of T'Class? Yes, but this doesn't work, because you don't know the discriminants for the object. Indeed, you don't even know how many there are or their types (since you can change the discriminants on extensions, including adding or removing them), so you can't even give them if you want to. People would have prefered this sort of solution, but it just doesn't work. >> 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); > >Yes it would be nice. However you will need something to get a parent's type >tag from the type tag. I proposed an attribute for that purpose: T'Parent_Tag. For Janus/Ada, the parent tag is stored in every tag, so this operation is very cheap. However, there were concerns about the fact that there are potentially two (related) parents for every type: the parent of the partial view and the parent of the full view. I think the attribute has to go to the parent of the full view, and since it is dynamic, the "privateness breaking" of that is not a real concern. >> -- Handling "least common denominator" comparison. > >BTW. Why not to allow tag comparisons >, >=, <, <=? I mean: > > function ">" (Left, Right : Tag) return Boolean; > >A>B if B is a descendant of A, but not of A type. These certainly are allowed if you write them yourself. Even if you had them, you still need a way to control the dispatching based on the result (once you've figured out the LCD). Randy.