Re: void and this
From: David B. Held (dheld_at_codelogicconsulting.com)
Date: 10/07/03
- Next message: Attila Feher: "Re: void and this"
- Previous message: Sergey Tolstov: "const qualifier and VC6.0"
- In reply to: Kevin Goodsell: "Re: void and this"
- Next in thread: Rolf Magnus: "Re: void and this"
- Reply: Rolf Magnus: "Re: void and this"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 7 Oct 2003 01:43:25 -0500
"Kevin Goodsell" <usenet1.spamfree.fusion@neverbox.com> wrote in message
news:H7sgb.1128$dn6.28@newsread4.news.pas.earthlink.net...
> David B. Held wrote:
> >
> > I understand the distinction and the history, but I still fail to
> > understand why (void) is frowned upon or viewed as "C".
> > I happen to like the explicit way in which it says "this function
> > takes no arguments".
>
> Well, I don't mean to be argumentative,
Don't apologize for disagreeing!
> but it seems to me that showing the function with no
> arguments is possibly a *more* explicit (or at least logical)
> way of showing that it takes no arguments than showing it
> with what appears to be a void argument. Granted, no C++
> programmer will actually be lead to believe that the function
> takes one argument of type void, but that is what the syntax
> suggests. This is why I agree that the syntax is an
> "abomination", as was stated elsewhere.
> [...]
Well, void doesn't quite work with metaprogramming, but it
should. I mean, how handy would it be if we could substitute
any number of void arguments in a template function? We
wouldn't need to write a hundred overloads! Like this:
int foo(void, void); // takes no arguments
Why would you want to do that? Why, so you could do this,
of course:
template <typename T1 = void, typename T2 = void, ...>
int foo(T1 t1, T2 t2, ...);
And voila! You just wrote N overloads that currently require
tedious cut-n-paste or preprocessor magic.
Anyway, I think of "void" as a "metanull". It's a metavalue
which indicates nothingness, like NULL, kinda. Would you
say that this is more "explicit"?
int* p = ;
Believe it or not, I see "int foo()" in a similar way, which
rubs me the wrong way just as the statement above
undoubtedly rubs most people.
Dave
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
- Next message: Attila Feher: "Re: void and this"
- Previous message: Sergey Tolstov: "const qualifier and VC6.0"
- In reply to: Kevin Goodsell: "Re: void and this"
- Next in thread: Rolf Magnus: "Re: void and this"
- Reply: Rolf Magnus: "Re: void and this"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|