Browse thread
Re: [Caml-list] productivity improvement
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alessandro Baretta <alex@b...> |
| Subject: | Re: [Caml-list] productivity improvement |
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 <reinterpret_cast> ... 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