News for hackers. Stuff that matters.
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++).

  type Vector* {.importcpp: "std::vector", header: "<vector>".}[T] = object
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.)

  template `[]=`*[T](v: var Vector[T], key: int, val: T)
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]").

  = {.emit: [v, "[", key, "] = ", val, ";"].}
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.
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.
Re:Nim Programming Language v0.16.0 released by evacchi on Monday January 09, 2017 @12:26PM (#13357940)
> (although I'm confused by the "[T]").

the `*` marker means that the proc/template is "public" (not local to the module)