3 ms·
it's an evolutionary (as opposed to revolutionary) language; it is in many ways a reimagining of c++ based on decades of observing the latter's flaws and weakne
by zem 2mo ago
it's an evolutionary (as opposed to revolutionary) language; it is in many ways a reimagining of c++ based on decades of observing the latter's flaws and weaknesses in the real world. if you're in the c or c++ ecosystem already you will likely find D a pleasant set of improvements to c++.
- WalterBright 2mo agoFor example, C and C++ still cannot compile this: int foo() { return bar(); } int bar() { return 3; }
- vips7L 2mo agoIs it because bar is defined after foo?
- WalterBright 2mo agoYes. It has deleterious consequences. One solution is to add a forward declaration, which is the kind of busywork a language is supposed to eliminate. Another is to reverse the natural order of functions, with the implementation functions at the top and the interface of the module at the bottom. After all, do you read a website from top to bottom or bottom to top?
- CapsAdmin 2mo agoLua has the same problem with local functions, and Lua was the first language I learned that I still use today. So it feels very natural for me to see local functions with no dependencies at the top, and the ones with the most dependencies at the bottom. (but you can work around this in lua with globals, forward declarations, functions in tables, etc) So I guess I kind of prefer seeing helper functions at the top and the main logic at the bottom most of the time.
- WalterBright 2mo agoBTW, that code snippet will compile properly with D's ImportC compiler. Proof that it is not impractical.
- zerr 2mo agoFunny that C89/C90 would compile this specific example just fine due to implicit function declaration feature, which was deprecated in C99.
- Joker_vD 2mo agoSo much for "well, C started its life with a single-pass compiler, so it simply couldn't be made to work" justification, which makes it false in two ways: we actually have the sources of the original C compiler, and it was two-pass.
- pjmlp 2mo agoBecause of stuff like ADL, the declaration order matters, thus I don't expect anyone ever submitting a paper to fix that. And even if that isn't a problem, given how ISO works, someone still needs to get that paper in and voted.