Thread: RE: (off-topic) RE: [Doxygen-users] Documenting IDL
Brought to you by:
dimitri
From: Wagner, V. <VW...@se...> - 2001-05-08 14:15:52
|
I didn't say operator int(), I said operator void* (). There is a large difference. the problem of 'adding' your own test is that it isn't the same as: real pointers STL iterators -----Original Message----- From: Stephen Goudge [mailto:ste...@pi...] Sent: Tuesday, 2001 May 08 09:31 To: dox...@li... Subject: (off-topic) RE: [Doxygen-users] Documenting IDL [deleted] Ah, the number of problems trying to do that caused me :-( 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. I would be tempted nowadays to try and hid IsValid(), but I take the attitude that if something was done because one compiler needed it (and the results are still legal) then keep it in, because the code will be used on a.n.other compiler next week, or the week after... 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 :-( Stephen Goudge _______________________________________________ Doxygen-users mailing list Dox...@li... http://lists.sourceforge.net/lists/listinfo/doxygen-users This transmission may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you |
From: Stephen G. <ste...@cl...> - 2001-06-08 09:53:29
|
[Just found this sitting unsent in my outbox and its still an interesting C++ issue, so:] > -----Original Message----- > From: dox...@li... > [mailto:dox...@li...]On Behalf Of Wagner, > Victor > Sent: 08 May 2001 14:16 > To: 'dox...@li...' > Subject: RE: (off-topic) RE: [Doxygen-users] Documenting IDL > > > I didn't say operator int(), I said operator void* (). There > is a large > difference. When starting this, I deliberately avoided addined an operator that could be mistakenly read as returning more information than it does - something that returns 'bool' is unambiguous, even the most neophyte "next new guy to join the team" isn't going to try and cast it to anything (which sounds a bit rude and snotty, but it is exactly the sort of thing that has happened). So far as any other code is concerned, _what_ is this large difference? The only use for this operator is in a test such as "if (ptr)" and bool seems to fit that idea quite nicely. > the problem of 'adding' your own test is that it isn't the same as: > real pointers Very true - for example, with 'real pointers' I wouldn't get upset if people wrote all their functions calls as Fum(MyPointer fred) whereas with ref-counted pointers, for example, you want to write Fum(const MyPointer& fred). These are not 'real pointers' and sometimes it is good to be reminded of this (and sometimes it is bad). > STL iterators Well, I admit to not having tried to combine the two (remember, this all started from old code, VC++2 days, which rather pre-dates a (working) copy of STL being available). If (when?) it becomes necessary to combine the two, that does not preclude leaving in 'IsValid()' - after all, to be an iterator you just need to provide the correct interface and after that you can add anything else you want. One day, no doubt, the two will coincide, when someone wants to feed one of these pointers to an STL algorithm, at which time it would be useful to know what the large difference is between using operator bool() and operator void *() - does the former stop something working? Regards, Stephen Goudge > -----Original Message----- > From: Stephen Goudge [mailto:ste...@pi...] > Sent: Tuesday, 2001 May 08 09:31 > To: dox...@li... > Subject: (off-topic) RE: [Doxygen-users] Documenting IDL > > [deleted] > > Ah, the number of problems trying to do that caused me :-( > > 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. > > I would be tempted nowadays to try and hid IsValid(), but I take the > attitude > that if something was done because one compiler needed it > (and the results > are > still legal) then keep it in, because the code will be used > on a.n.other > compiler next week, or the week after... > > 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 :-( > > Stephen Goudge > > > _______________________________________________ > Doxygen-users mailing list > Dox...@li... > http://lists.sourceforge.net/lists/listinfo/doxygen-users > > > This transmission may contain information that is privileged, > confidential > and exempt from disclosure under applicable law. > If you are not the intended recipient, you are hereby > notified that any > disclosure, copying, distribution, or use of the information contained > herein (including any reliance thereon) is STRICTLY PROHIBITED. > If you received this transmission in error, please > immediately contact the > sender and destroy the material in its entirety, whether in > electronic or > hard copy format. > Thank you > > > > _______________________________________________ > Doxygen-users mailing list > Dox...@li... > http://lists.sourceforge.net/lists/listinfo/doxygen-users > |
From: Victor A. W. Jr. <va...@ru...> - 2001-06-08 12:37:05
|
I'll try to answer best I can...... replies in the text At Friday 2001/06/08 06:53, you wrote: >[Just found this sitting unsent in my outbox and its still an interesting C++ >issue, so:] > > > -----Original Message----- > > From: dox...@li... > > [mailto:dox...@li...]On Behalf Of Wagner, > > Victor > > Sent: 08 May 2001 14:16 > > To: 'dox...@li...' > > Subject: RE: (off-topic) RE: [Doxygen-users] Documenting IDL > > > > > > I didn't say operator int(), I said operator void* (). There > > is a large > > difference. > >When starting this, I deliberately avoided addined an operator that could be >mistakenly read as returning more information than it does - something that >returns 'bool' is unambiguous, even the most neophyte "next new guy to >join the >team" isn't going to try and cast it to anything (which sounds a bit rude and >snotty, but it is exactly the sort of thing that has happened). > >So far as any other code is concerned, _what_ is this large difference? >The only >use for this operator is in a test such as "if (ptr)" and bool seems to >fit that >idea quite nicely. But it isn't really a bool. If you write operator bool() then it could be used anywhere a bool is valid (not just in if and while). I'm just following several authors dictum (when in doubt, do what the built in types do...in this case, I consider the STL 'built in') > > the problem of 'adding' your own test is that it isn't the same as: > > real pointers > >Very true - for example, with 'real pointers' I wouldn't get upset if people >wrote all their functions calls as Fum(MyPointer fred) whereas with >ref-counted >pointers, for example, you want to write Fum(const MyPointer& fred). These are >not 'real pointers' and sometimes it is good to be reminded of this (and >sometimes it is bad). > > > STL iterators > >Well, I admit to not having tried to combine the two (remember, this all >started >from old code, VC++2 days, which rather pre-dates a (working) copy of STL >being >available). If (when?) it becomes necessary to combine the two, that does not >preclude leaving in 'IsValid()' - after all, to be an iterator you just >need to >provide the correct interface and after that you can add anything else you >want. > >One day, no doubt, the two will coincide, when someone wants to feed one of >these pointers to an STL algorithm, at which time it would be useful to know >what the large difference is between using operator bool() and operator void >*() - does the former stop something working? > >Regards, >Stephen Goudge 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" |