home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: zero-length datatype
- Message-ID: <TMB.92Sep11212337@arolla.idiap.ch>
- Date: 12 Sep 92 01:23:37 GMT
- References: <TMB.92Sep8141523@arolla.idiap.ch> <4947@holden.lulea.trab.se>
- <HAYDENS.92Sep9215705@bullwinkle.juliet.ll.mit.edu>
- <TMB.92Sep10120206@arolla.idiap.ch>
- <HAYDENS.92Sep10103208@bullwinkle.juliet.ll.mit.edu>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Distribution: comp
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 32
- In-reply-to: haydens@bullwinkle.juliet.ll.mit.edu's message of 10 Sep 92 17:32:08 GMT
-
- In article <HAYDENS.92Sep10103208@bullwinkle.juliet.ll.mit.edu> haydens@bullwinkle.juliet.ll.mit.edu (Hayden Schultz x3685 g42) writes:
-
- I'm still not convinced that you can't use existing language features
- to solve (or maybe just avoid) this problem. If a legitimate subset of
- the hash table problem is hash tables with just keys, then this sounds
- like a basis for a class heirarchy. [... example deleted ...]
-
- I think that this meets your intuitive criterion. Whenever you don't
- care what the values are, you use the KeyHash class. You don't have to
- make a special class to make a simple HashTable<int,int>. The Key and
- Value types are as explicit as your original example. You don't even
- have to modify any existing code which uses the HashTable class, since
- the public interface hasn't changed.
-
- The number of classes you need might be large. Consider the following:
-
- template <class A,class B,class C>
- class XYZ { ... }
-
- Now, you already need 7 different versions of XYZ, depending on which
- of "A", "B", "C" are "void" (assuming not all of them are "void"
- simultaneously), and it is not clear that every such class can be
- decomposed neatly into a class hierarchy, even with multiple
- inheritance.
-
- So, sure, you can reorganize your code and introduce several classes
- (there are other, less object-oriented and more general approaches as
- well). However, why bother? "void" can be a perfectly good data type,
- and it has proven its utility in other languages. It's no big deal, it
- is simply that the restrictions on it in C++ seem arbitrary.
-
- Thomas.
-