4 ms·
I hadn't seen this language before, but it looks neat. Coming from a Ruby background, it's very interesting to see Nim's pragmas and templates, as they look rat
by zyxley 12y ago
I hadn't seen this language before, but it looks neat. Coming from a Ruby background, it's very interesting to see Nim's pragmas and templates, as they look rather like type-checked and compiled cousins of metaprogramming methods.
- hliyan 12y agoI concur. This is the first time I'm seeing it too. I come from a C++ background, with recent experience in Python and JavaScript. I'm rarely impressed by new languages, but for some reason, Nim feels like what I wish Python was.
- progman 12y agoIndeed. But Nim is much more expressive than Python. A very nice feature of Nim is clean macros. They support regular string matching in native Perl syntax. For instance. if line =~ rx"http[s]://(.+)": var url = matches[0] ... where rx is defined as: # partial regular expressions as in Perl template rx * (arg: expr): expr = re(r".*?" & arg & ".*") Another macro instance: template repeat * (body: stmt): stmt {.immediate.} = block: while (true): body template until * (cond: expr): stmt {.immediate.} = block: if cond: break # Sample: # # var i=0 # repeat: # echo i # i += 1 # until i==7 Nice, isn't it?