RE: (off-topic) RE: [Doxygen-users] Documenting IDL
Brought to you by:
dimitri
From: Victor A. W. Jr. <va...@ru...> - 2001-06-11 13:19:41
|
or use void* like I ORIGINALLY suggested (and is suggested by looking at how the STL does it with iterators. At Monday 2001/06/11 09:37, you wrote: > > -----Original Message----- > > From: dox...@li... > > [mailto:dox...@li...]On Behalf Of Hendrik > > Schober > > Sent: 10 June 2001 20:58 > > To: dox...@li... > > Subject: Re: (off-topic) RE: [Doxygen-users] Documenting IDL > > > > > > "Stephen Goudge" <ste...@pi...> wrote: > > > > > [...] > > > I did originally have an operator int() that could be used > > in if-statements, > > > which worked fine using VC++2 through to VC++4; then a > > client bought VC++5 and > > > it became ambiguous (I forget the precise reason why), so > > everything switched to > > > IsValid() from then on. > > > > 'int' seems like one of the most troublesome ideas. > > (What's 'spa+spb' to become then?) > > > > > [...] > > > Even with a decent compiler, there is the vexed question of > > what the cast > > > operator should be casting _to_ - you don't really want to > > return another > > > pointer type, as that looks too much like you're providing > > a backdoor. These > > > days, 'bool' would be a reasonable choice (now that the > > compilers actually > > > support 'bool'). The best choice would be the mythical > > 'logical' type that 'if', > > > 'while' etc use, but that isn't available :-( > > > > Oh, but that's available: It's named 'bool'. > >The "the mythical 'logical' type that 'if', 'while' etc use" is not 'bool' - I >suppose you could produce a parser that used bool there, but just taking a >straw >poll around the office, the guy sitting next to me (working on a C compiler) >uses 'long int' for 'if' etc, which is what the Standard says you do >(hence the >use of operator int() to feed 'if' in the oldest code). Meanwhile, in my >program, a C-expression evaluator has a type 'logical' that is only used >internally (ie, from the point of view of someone writing an expression to be >evaluated, is mythical because you can not declare anything to have type >'logical') and lives at the very opposite end of the automatic type promotion >ladder from 'bool'. > >Also, unfortunately, all that time ago, 'bool' was not available in all the >compilers being used :-( > > > But 'bool' isn't all that good either, because it's an > > arithmetic type. (Or was it convertible into one?) > > You could thus write 'sp+5' and get funny results. > ><snip> > >That points out the problem exactly - all of the types that you can use here >already have well-known meanings and tend to imply that it is possible to use >them in expressions _other_ than just 'if'. No matter what you choose, you can >write something that will give funny results. > >Hence (not to be taken too seriously) wish to be able to use a type, >'logical', >that does not carry any such baggage, based on the fact that I _know_ such a >type does/can live deep within the bowels of a compiler. > >The _only_ answer I know of that is possible to implement _and_ totally >free of >any such baggage is an "IsValid()" method - which is right back to where we >started. > > > In his book "Modern C++ Design" Andrei Alexandrescu > > discusses this issue. His idea (typing from memory): > > > > template<class T> > > class SmartPtr { > > private: > > class Tester { > > void operator delete(void*); > > }; > > public: > > operator Tester*() const > > { > > if( !IsValid() ) > > return NULL; > > static Tester tester; > > return tester; > > } > > // ... > > }; > > > > (The private 'operator delete()' is there to prevent > > users from trying to delete the result of calling the > > convertion operator.) > > > > I have not used this yet, so I don't know whether it's > > really as great an idea as it seemed to me. > > > > > Stephen Goudge > > > > Schobi > >Aha, yet another approach :-) > >The suggestions - _all_ of them - all have their merits and all can all work >extremely well, but, just like the search the One True String Class, there >is no >absolute best answer to this. Shame really. > >Now, back to Doxygen... > >Stephen Goudge > > > >_______________________________________________ >Doxygen-users mailing list >Dox...@li... >http://lists.sourceforge.net/lists/listinfo/doxygen-users Victor A. Wagner, Jr. PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93 The five most dangerous words in the English language: "There oughta be a law" |