Subject: Re: making virtual functions in CL From: Erik Naggum <firstname.lastname@example.org> Date: 1999/01/18 Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * "Harley Davis" <spamless_davis@spamless_ilog.com> | I am not clear as to why Erik feels that C++ is especially flawed for | this, other than that its syntax is screwy as usual (no keywords for | abstract classes; need to define a pure virtual to make a base class | abstract; pure virtual function definition syntax is silly.) There is a | reasonable argument that C++ simply lets you specify too much or requires | you to overdesign your class hierarchies to take advantage of all the | static declarations you can make, but I'm not sure if this is what Erik | is getting at. the problem with C++ is that it pretends to give you something, but fails to follow up on it and actually deliver it. (this is not unlike most C++ projects, but I digress.) in this case, a pure virtual function is a good idea that never got anywhere. it tries to answer the desire for a protocol between class designer and subclass implementor, but only the first subclass needs to implement it, yet if that one forgets it, some subclass of that class might need to, and despite all the "statically typed" nonsense, it doesn't really enforce any of this protocol. it's worse to pretend you give somebody something valuable than not to give it. | BTW, I have played around in Lisp with various ways to define abstract | protocols declaratively rather than dynamically. I think it is fairly | easy to find a solution using the MOP and some additional macros/keywords | as Erik suggests. But it's not very easy getting the compiler to check | the result as in C++ and Java. (FYI, in C++ and Java the compiler will | not normally let you instantiate an abstract class.) sure, but that's the only bonus you get, and it isn't the one you want, which is a way to make sure subclasses that change something that the virtual function needs will also supply an implementation of that function. this is actually fairly tricky stuff. C++ has taken the easy way out and did something that looks good to people who don't care to think too much about what they get. stuff like that really bugs me. #:Erik -- SIGTHTBABW: a signal sent from Unix to its programmers at random intervals to make them remember that There Has To Be A Better Way.