Re: void func () returning value?
mark_bluemel@po box.com wrote:
It is more about the ability to recognize "natural" where it is indeed present.
Someone already demonstrated an example of C++ template code that shows where
this feature can be extremely useful. However, it is absolutely unnecessary to
drag C++ and templates here for that purpose, because C language already has
everything necessary to achieve the level of generality that makes that feature
useful. The example follows
typedef int T;
T foo() { ... };
T bar() { return foo(); }
T baz() { return foo(); }
In at some point in the future I might decide to change the typedef to
typedef void T;
I'll have to comb through the entire program's source code and break all such
return statements into two lines. (And repeat the whole thing again when I
decide to change it back). That is heavily UNnatural. The support for "return
void" would solve the problem in a very elegant way.
So the feature in indeed objectively natural, but unfortunately it is not even
in C99.
--
Best regards,
Andrey Tarasevich
mark_bluemel@po box.com wrote:
...
>
I thought it was unnatural - funny how people's interpretation of
"natural" varies...
...
>I thought it was
>natural to do 'return func()' for func() returning nothing,
>natural to do 'return func()' for func() returning nothing,
I thought it was unnatural - funny how people's interpretation of
"natural" varies...
...
Someone already demonstrated an example of C++ template code that shows where
this feature can be extremely useful. However, it is absolutely unnecessary to
drag C++ and templates here for that purpose, because C language already has
everything necessary to achieve the level of generality that makes that feature
useful. The example follows
typedef int T;
T foo() { ... };
T bar() { return foo(); }
T baz() { return foo(); }
In at some point in the future I might decide to change the typedef to
typedef void T;
I'll have to comb through the entire program's source code and break all such
return statements into two lines. (And repeat the whole thing again when I
decide to change it back). That is heavily UNnatural. The support for "return
void" would solve the problem in a very elegant way.
So the feature in indeed objectively natural, but unfortunately it is not even
in C99.
--
Best regards,
Andrey Tarasevich
Comment