is the case of poorly designed syntax, in a truly Hindley-Milner system there is
no expression which doesn't have a type. Now, we could add some syntax that
screws that up, say:
let v = I-HAVE-AN-AMBIGUOUS-TYPE in 0
But that's rather silly, isn't it? If a value isn't used then I would,
personally, like my language to optimize it away. So why not ditch such silly
syntax?
This is part of why I said that the foundations of C++ are too far-gone.
And this syntax isn't necessary to save on typing. In a language that supported
syntactic macros (such as Scheme or Racket) we could write something like:
auto items = my-vector-syntax(1,2,3,4);
which expands to something like:
auto items;
items.push_back(1);
items.push_back(2);
items.push_back(3);
items.push_back(4);
If you're interested in true syntactic macros for non-sexp languages (though I
do suggest getting over the parentheses, my color settings make them nearly
indistinguishable from the background) look at Rust [1].
Actually, Rust also has type inference [2].
Hell, stop programming in C++ and start using Rust! [3]
Having programmed Haskell for the last seven years (and C++ for zero) I have a fairly decent handle on what HM is all about. If all you had said is that the foundations of C++ are too far gone, there wouldn't be anything to discuss. But the foundations of C++ being what they are, there's no point being offended when unfixable things go unfixed. I love HM, but you can't just throw it in any old language simply because it's cool. The language's semantics need to allow for it, and they just don't with C++.
No need to downvote this; I'm an enthusiastic Rust follower and I as well recommend that you stay far away from Rust until it settles down a bit. Wait for 0.5 if you're adventurous, 0.6 if you expect some degree of feature-completion, 0.7 if you're fine with half-finished standard libraries, and even later if you expect a high degree of stability, ergonomics, documentation, or performance.
This is part of why I said that the foundations of C++ are too far-gone.
And this syntax isn't necessary to save on typing. In a language that supported syntactic macros (such as Scheme or Racket) we could write something like:
which expands to something like: If you're interested in true syntactic macros for non-sexp languages (though I do suggest getting over the parentheses, my color settings make them nearly indistinguishable from the background) look at Rust [1].Actually, Rust also has type inference [2].
Hell, stop programming in C++ and start using Rust! [3]
[1] http://dl.rust-lang.org/doc/tutorial-macros.html [2] http://dl.rust-lang.org/doc/0.4/rust.html#type-system [3] http://www.rust-lang.org/