From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA30574; Fri, 19 Jul 2002 12:06:47 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA30570 for ; Fri, 19 Jul 2002 12:06:46 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a136.tin.it [62.211.4.136]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6JA6j105862 for ; Fri, 19 Jul 2002 12:06:45 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 4F7FA2724F; Fri, 19 Jul 2002 12:14:01 +0200 (CEST) Message-ID: <3D37E669.6050608@baretta.com> Date: Fri, 19 Jul 2002 12:14:01 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: it, en MIME-Version: 1.0 To: Andreas Rossberg , ocaml Subject: Re: [Caml-list] productivity improvement References: <20020716172916.4903.qmail@web10702.mail.yahoo.com> <200207190358.XAA11620@dewberry.cc.columbia.edu> <20020719010318.B3631@boson.den.co.bbnow.net> <200207190821.EAA09974@hickory.cc.columbia.edu> <3D37D474.2551F19E@ps.uni-sb.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Andreas Rossberg wrote: > Oleg wrote: >> >>Correct. Since C++ compiler can not possibly know of all existent sub-types, >>there is no way it can warn you. This is why virtual member functions are >>still preferred. > > And how would you do more complex case analysis, corresponding to nested > patterns? This is more than cumbersome and error-prone in C++ - with > RTTI, and even more so with method dispatch, where your single algorithm > will have to be scattered over tons of distant functions. A maintenance > nightmare. > > BTW, as Issac noted, you cannot even use switch statements to perform > RTTI in C++. You have to program if cascades. > Yes, but RTTI is a hack. Nobody would seriously "plan" to use RTTI during the design stage of a software system. You just "happen" to need RTTI when most of the code is already there and you realize there is a bug in the specification which would require to redesign the inheritance hieararchy. In such cases you go with RTTI. Otherwise, you'd stick to simple OO polymorphism, which is the "Right Way(TM)" to use case/pattern matching constructs in C++. In C++ all you have to encapsulate runtime types is the class construct. Because of its native polymorphism, one could argue that RTTI and case statements are never really needed. The only arise out of design errors. Of course, the latter seem to be fairly frequent in a language that does not enforce sensible coding conventions. Consider ... Alex ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners