Re:Nim Programming Language v0.16.0 released
by majewsky on Monday January 09, 2017 @10:35AM
(#13357032)
It took me a moment to parse, but that snippet is actually pretty straight-forward when you know that Nim compiles down to C (or C++).
This obviously creates a type "Vector" whose underlying implementation is C++'s "std::vector". (I don't know how writeable it is, but it is* readable.)
Function declaration syntax for operator overloads is hard to make readable (as in: familiar). In fact, this is about as readable as it can get (although I'm confused by the "*[T]").
As I said, when you know that the compiler generates C code, this makes a lot of sense. It's a compiler instruction to compose a string of C code.
[ Parent
| on HN ]
Re:Nim Programming Language v0.16.0 released
by vgbm on Monday January 09, 2017 @12:54PM
(#13358165)
To supplement the other response, [T] declares a generic type, so [T] is a public method with the generic type T. I'd agree though that the is initially hard to parse, especially when taking C and C++ into account, where * means something entirely different.