A quote from the article:
---[ Begin ]---
It is obvious to both me and the compiler that the function is returning a double. So in C++14, I can define the function return type as auto instead of double:
auto getvalue() {
return 1.4;
}
---[ End ]---
I think this is potentially very dangerous. Suppose I meant to type 1.4f
but forgot the f? This will not catch that error, and may only generate
a warning elsewhere which another developer sees as "oh, I just need to
cast it to double to get rid of that ridiculous warning," and inserts a
new bug and does not correct the original flaw which would've actually
fixed the first bug and prevented the second.
I believe strongly in an explicit conveyance of developer information
through syntax. For example, getvalue() should be declared thusly:
double getvalue(void) {
return 1.4;
}
In this case the return type was explicitly given, and you explicitly
indicated that you, as the developer, purposefully had no parameters,
rather than leaving a potential questiont here: Did the developer
intend to pass any parameters? When "void" is used, there is no
ambiguity as it's much harder to accidentally type "void" than it is
to accidentally leave off parameters in an otherwise valid syntax
such as "double getvalue()".
I also think we should do away with .h files when they're not necessary,
and instead provide something like:
#includeh "myclass.cpp"
Which is interpreted by the compiler as "read myclass.cpp, but only
derive its information to create what we need to access it, as would
othemrwise be provided by a header."
In a similar manner, an IDE should be able to divine this information
for you and present a read-only, on-the-fly created header file that
can be logically wielded, examined, printed, etc., but rather stems
directly back to the actual cpp source code rather than a separate
file. It also saves disk space. (LOL had to throw that in there :-))
Oh I can't wait to get my compiler written. :-) All of these life and
living requirements make it painful to pause as the months roll by. :-)
Best regards,
Rick C. Hodgin