4 ms·
I've seen this fn/var argument a few times, but its a really that much harder to write a parser that can intuit the difference between a function/variable/state
by StillBored 4y ago
I've seen this fn/var argument a few times, but its a really that much harder to write a parser that can intuit the difference between a function/variable/statement without explicitly putting function/var/let/etc all over the place?
I like the verbosity of a language like pascal, but I just find it jarring in a C replacement these days. (and rust's structure definitions/etc I just find needlessly verbose for the way I use C structures).
C is nice because its fairly easy to mentally parse (C++ less so) vs some of the alternatives, while still being extremely concise.
- xigoi 4y agoThe C way makes it hard to find the name of the function (or even tell that it's a function declaration) when the return type is long. std::vector<std::unordered_map<std::string, std::pair<std::string, std::string>>> foo(std::vector<std::vector<int>> x, std::unordered_map<std::string, std::string> y);
- StillBored 4y agoI said C++ was diff, but how about: using namespace std; typedef vector<unordered_map<string, pair<string, string>> foo_bar_xref; foo_bar_xref foo( vector<vector<int>> x, unordered_map<string, string> y); not sprinkling std:: everywhere helps with readability, but so does defining a couple types used frequently, especially if they are particularly verbose. And of course the parser doesn't really have a problem with this, so your editor should be able to find it with its 'goto declaration' function. I don't feel pity for people who chose to use editors/IDEs that make this difficult.
- xigoi 4y ago> not sprinkling std:: everywhere helps with readability I agree, but most C++ programmers don't :/ > And of course the parser doesn't really have a problem with this, so your editor should be able to find it with its 'goto declaration' function. C++ syntax is Turing-complete, so due to the halting problem, finding the declaration can take a long time, potentially unlimited in pathological cases.
- int0x80 4y ago>C++ syntax is Turing-complete, so due to the halting problem, finding the declaration can take a long time, potentially unlimited in pathological cases. Absolutely not unlimited time. Once it's parsed and semantically analyzed you can find the declaration in no time. Exactly like the compiler does. edit: to clarify, I was not taking into account unbounded recursion on template instantiation, which should be limited in any case by the compiler.
- int_19h 4y agoThe problem historically is that "using namespace" was undesirable in headers, since it would apply to anything that included them. And with the tendency for modern idiomatic C++ to be heavily templated, many function bodies have to be in the headers.
- mauvia 4y agoYou can use using = instead of typedef using namespace std; using foo_bar_xref = vector<unordered_map<string, pair<string, string>>; foo_bar_xref foo( vector<vector<int>> x, unordered_map<string, string> y);
- wtetzner 4y ago> (and rust's structure definitions/etc I just find needlessly verbose for the way I use C structures) Do you have an example? What's verbose about Rust struct syntax?