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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3ef3e78eacf6f938 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,CP1252 Path: g2news2.google.com!postnews.google.com!q11g2000yqi.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Hibou57_=28Yannick_Duch=EAne=29?= Newsgroups: comp.lang.eiffel,comp.lang.ada Subject: Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3? Date: Tue, 21 Jul 2009 07:08:52 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 77.198.58.8 Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1248185333 16720 127.0.0.1 (21 Jul 2009 14:08:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 21 Jul 2009 14:08:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q11g2000yqi.googlegroups.com; posting-host=77.198.58.8; posting-account=vrfdLAoAAAAauX_3XwyXEwXCWN3A1l8D User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; fr),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.eiffel:364 comp.lang.ada:7234 Date: 2009-07-21T07:08:52-07:00 List-Id: On 21 juil, 03:33, Cesar Rabak wrote: > Does the subtyping in Ada complain if one makes an operation on two > variables of type Length (here defined as 'type Length is new Float;') > that there is not a compatible Length squared defined? Yes it will, providing you've design things to go this way (compilers are still automata, not form or artificial with capabilities to read in your minde). For your example, you may first define a private type, so that the user of the type (except package implementation and child package) cannot rely on its representation (a black box). You may define initializers, which would be required, as the user would not be able to initialize any value otherise. Ex. =93 function To_Length (Value : Natural) return Length_Type =94 or =93 procedure Set (Length : in out Length_Type; Value : Natural); =94. You may also have a =93 type Length_Squared_Type is private; =94, private as well and a function =93 function Length_Squared (Left, Right : Length_Type) return Length_Squared_Type; =94. As you see, you can have a fully secured set of specifications : the user can do only what is defined, and nothing else. So it is easy to enforce Length_Type * Length_Type to be of type Length_Squared_Type. Beceause the user cannot do a direct Length_Type * Length_Type and must use the function you provide in this purpose. Note : as Length_Type and Length_Squared_Type would probably be defined in the same package specification, then Length_Squared_Type could not derived from Length_Type (language rules), and and if you want to use the same representation for both they could just both derives from a base representation type which could not exist in the public speficiation of the package, and then a little convertion will be needed in the implementation. However, it would probably be nice to have a wider type for Length_Squared_Type and to not have the same representation (unless the Length_Type is designed so that there is never an overflow when computing a Length_Squared_Type). I apologize for details, as I'm not sure you know Ada well (it seems this thread is broadcasted in multiple comp.lang.* at the same time). But even with your Eiffel skills, I think it is possible to understand the most important aspects.