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,1dd28d5040ded1f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-23 04:38:35 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!pec-17-144.tnt5.hh2.uunet.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Announce: Grace project site operational Date: Thu, 23 May 2002 13:40:54 +0200 Message-ID: References: <3CE15D0A.3050100@mail.com> <2s44eu0fm4g6606h9p4stb1b5oc0nmg5u8@4ax.com> <3CE2A946.5030808@mail.com> <3CE40B8E.70102@mail.com> <3ucneuoh5kgemqpoq85ts5v7lolnk760bn@4ax.com> <3CEBC7C9.10604@mail.com> NNTP-Posting-Host: pec-17-144.tnt5.hh2.uunet.de (149.225.17.144) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1022153913 27477393 149.225.17.144 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:24575 Date: 2002-05-23T13:40:54+02:00 List-Id: On Wed, 22 May 2002 12:31:05 -0400, Hyman Rosen wrote: >Dmitry A. Kazakov wrote: >> It is not much better than: #define private public. > >I don't understand what this means. If you do this inconsistently, >you are violating the rules of the language, and the result is >undefined behavior. I cannot imagine how this is related to templates. The problem is that you cannot gain very much by checking the program against specifications alone. That is not enough, you need the body = implementation. You might argue that it is no matter because to change the implementation one need to recompile the whole system. But I doubt that this another disadvantage of generics is an excuse. > > So far the result >> remains a valid programs it is fine! That actual has or has not plus >> will be checked in C++ only after substitution. One need body to check >> that! Consider that somebody has instantiated your template, but did >> not use the bodies where + is used. No error, though the contract is >> broken. Well, after 10 years or so, somebody would try to use that >> bodies and run at misterious errors in the code which is supposed to >> be safe. > >Once they try to use the body, the code will fail to compile. >This will not be unsafe in the sense of causing the program >to behave improperly, since it will not build at all. Yes, but you should agree that for a large project that could be unacceptable. >Therefore, it is difficult, and likely >useless, for a template writer to specify some definite origin >for the operator. The only purpose will be to limit the utility >of the template. I agree with you but for other reason. If you can specifiy the formal type as type Thing is new Field with private; then probably you need no generic at all. Because if declaring objects of Thing and operations on Thing is all what you need, then Field'Class would perfectly do the work. So my original point, if a language has a good type system, then there is little need in generics. Class-wide programming might supersede programming with generics. I strongly believe that as ADT will progress, generics will become sort of GOTOs = use only if you really need it, once in your life. >Nevertheless, some people (like you!) want this kind of checking >anyway, and it is possible to code the checks in C++, through a >process called "concept checking". This uses template metaprogramming >to cause templates to fail to compile when instantiated with types >that fail the concept check. That's good, but not enough, because the semantic of the operator + might be different. For instance, not all floating-point algorithms are working on integers. So your program might pass the compiler and yet be corrupt. Templates violate LSP too readily. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de