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-Thread: 103376,1a52c822fc0dbb23 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!138.195.8.3.MISMATCH!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Rational for not making cursor tagged in Containers Date: Fri, 20 Apr 2007 15:11:53 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1176998738.656903.141250@q75g2000hsh.googlegroups.com> <1177010938.200523.325290@p77g2000hsh.googlegroups.com> <1a8y2vakorfhx.225uqh4hifpd$.dlg@40tude.net> <1xmzi7newnilp.23m3zze8h9yi.dlg@40tude.net> <1177066583.5876.30.camel@localhost.localdomain> <1177080147.5876.87.camel@localhost.localdomain> <1q1kx2jlcvnuj.ck0711mj4few$.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1177099799 3584 69.95.181.76 (20 Apr 2007 20:09:59 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 20 Apr 2007 20:09:59 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Xref: g2news1.google.com comp.lang.ada:15172 Date: 2007-04-20T15:11:53-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:1q1kx2jlcvnuj.ck0711mj4few$.dlg@40tude.net... ... > Also I fail to understand why polymorphic objects has to be records > and not arrays or access types. Why array or number cannot have > discriminants, but records can? This ones easy. There is a fundamental difference between elementary types (which can represent only one value) and composite types (which can contain multiple values). Adding discriminants to an elementary type would turn it into a composite type -- and that way lies madness. As far as why a polymorphic object has to be a record, that's simply because it is the most general composite type. It is a heterogeneous container. Indeed, I don't think I've ever implemented an abstraction as anything else (at least not for long); there is always a need for additional items beyond the main data. The better question is why there are arrays at all. A homogeneous container is by definition more limited than a heterogeneous one. So, the ideal language would find a way to completely unify arrays and records. Perhaps the array syntax would have to remain, but it would just be a language defined synonym for a record access. I suppose you could try to do something similar for elementary types (you can use special syntax if there is only one component in the container), but that would necessarily make programs fragile (adding a component would necessarily disallow that syntax, requiring massive changes). So, I guess the ideal language would be one in which everything was a controlled record type. (For Janus/Ada, that's already true in many cases: a protected type is just a special controlled record type; task objects are essentially controlled, unconstrained arrays are really records that contain bounds and a data pointer, etc.) But such a language would be pretty space-inefficient (you could optimize individual calls to avoid dispatching, but there is no way to eliminate the space overhead, because you can never tell what might be done in some separately compiled unit.) Randy.