On Sat, Feb 21, 2004 at 12:44:27PM +0100, Julian Mehnle wrote: > Andrew Suffield wrote: > > C++ does not have an undef value. Where's your undefined integer? Nor > > does it have accessible multi-valued returns - you have to define an > > entire class to do it. > > "an entire class" -- Yeah, so what? It can be as simple as: > > class Int { > public: > int x; > Int(): x(0) {}; > Int(int new_x): x(new_x) {}; > }; > > Int* value; > value = 0; // undef > value = new Int(0); // 0 > > (I'm sure you knew that already.) It's not a significant problem. A class is not an enormous monstrosity with regard to memory consumption or code required for handling them. In such simple cases, there isn't even a need for RTTI, which makes the compiled code nearly as efficient as using built-in ints. > > And, how do you think does Perl handle *internally* scalar values which may be undef? Until every word of memory has its own "is_null" bit (similar to what most databases do), there won't be another way, and C++ handles it not too bad. > > > It makes it harder to avoid using exceptions. > > Why? Defeats the point. If you're going to go to that much effort, you might as well just throw an exception and have done with it. -- .''`. ** Debian GNU/Linux ** | Andrew Suffield : :' : http://www.debian.org/ | `. `' | `- -><- |
Attachment:
signature.asc
Description: Digital signature