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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,342dcd67e9ca73ee X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail From: "Hyman Rosen" Newsgroups: comp.lang.ada Subject: Re: tagged record child: override constructor? Date: 15 Sep 2005 11:54:15 -0700 Organization: http://groups.google.com Message-ID: <1126810455.448696.262570@g44g2000cwa.googlegroups.com> References: <1126591134.797303.318920@z14g2000cwz.googlegroups.com> <1uri5gd2n7om0.1ujkzb26ayxdx.dlg@40tude.net> <1126625009.709876.226260@f14g2000cwb.googlegroups.com> <225337460.SlYKbeB8eD@linux1.krischik.com> <87vf14him5.fsf@ludovic-brenta.org> <1idpvzxcxfckw.mrs8nw3eu4ks$.dlg@40tude.net> <13wyu4lwsmzmz.ktc3t2av54yv$.dlg@40tude.net> <1126705974.984997.227590@z14g2000cwz.googlegroups.com> <1126718176.448703.193860@g44g2000cwa.googlegroups.com> <1aroipmwspnb8.zqxtxhb4t06u$.dlg@40tude.net> <1126731371.081850.90860@g44g2000cwa.googlegroups.com> <12v93t1k4i81i$.sm5jmg8q3lpk$.dlg@40tude.net> <1126790380.573573.78220@g44g2000cwa.googlegroups.com> <1w82ustqd4vak$.mv9c3tcxa6sx.dlg@40tude.net> NNTP-Posting-Host: 204.253.248.208 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1126810460 28435 127.0.0.1 (15 Sep 2005 18:54:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Sep 2005 18:54:20 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 (No IDN) Firefox/1.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g44g2000cwa.googlegroups.com; posting-host=204.253.248.208; posting-account=lJDDWg0AAACmMd7wLM4osx8JUCDw_C_j Xref: g2news1.google.com comp.lang.ada:4744 Date: 2005-09-15T11:54:15-07:00 List-Id: Dmitry A. Kazakov wrote: > There is no actual type, there is only the type specified by the contract. There is an actual type, and it can be recovered from the object through redispatching (or even by simply extracting the type tag, if I'm not mistaken). > That's your view on OO, which is clearly inconsistent with the notion of > types. Perhaps with your notions of types. > is "by-reference" a type property? Yes. In C++ you have "type" and "reference to type" and the two are completely different. A "reference to type" may have as its referant a sub-object of the given type which is a base class of a larger object. An object of "type" is exactly that. Both of these concepts are useful. > Why by-copy objects (of which type?) have one (which?) type while > by-reference objects (of which type?) have more than one? It's not the "by-copy" that gives something a type. When you declare that a parameter has a class type, it has that type and nothing more. It's a separate object within its lifetime, and when the function is called, it's initialized with a copy of the argument. When you have a parameter of reference type, when the function is called it's initialized to refer to the appropriate subobject of the argument. (Actually, newbies in C++ face the same confusion between paramaters of T and T& as Ada newbies do between T and T'Class.) > It is rubbish. In a typed language an object has a type, only one type. You may not like it, but that's the way it's done, including in Ada. > No. Trap is when the declared type does not determine what's going on. In C++ the declared type does determine what's going on. In Ada, you are permitted to go from the declared type to the classwide type, so by your argument C++ reflects the contract model better than Ada does. > I (again) formulate the properties of Ada's model: But no Ada compiler implements the model the way you would like it to be. And I believe that allowing conversion from T to T'Class is a requirement of Ada. > Now show me how C++ or Java could accomplish 1..12. C++ doesn't have polymorphic variables or copying, so some things are out of reach. But the main problem with your approach is that no one wants to implement differently sized pointers for T'Class than for T. For all your posting on this, I've yet to see an implementor so taken by your approach that he's willing to adopt it. > What should that code prove? That pointers to members is a total mess in > C++? Everybody knows it. It proves that they're equal. *That's* what everyone knows. > I don't know what "separate" members are. Do you mean memory location? Why > should I care of? I mean "different", or "distinct", or "not the same", or any other synonym you care to pick. > They cannot be same because they act on different types. You cannot call > B::g() on A. The same question again, is C++ typed? As I said, in OO languages like Ada, C++, and Java, when you have a reference type, the object to which it refers may be a typed base subobject of a larger object of different type. There is only an A::g(), and it operates on an A object which is standalone or which is a base subobject of an object of a class derived from A. Because B inherits g() from A, you may also refer to it as B::g, much as Ada lets you rename one thing as another, but it is only a different name for the same thing. And if you have a 'B b;' it's perfectly legal to say 'b.A::g();'. > X->B::g (); // Error, how so? X is of B, or maybe not quite? Because the rules of C++ (3.4.5/4 of the Standard, if you would like to check) say that the name preceding the :: is first looked up in context. There is no B in A, so it simply fails to compile without ever getting to consider the g() part.