I'm not sure how to use the new {.this.} pragma, that lets us use shortcutted syntax that adds in an implicit "this" when possible.
type Bar = object
baz: int
{.this: self.}
proc foo(self: Bar):
echo(baz)
foo(Bar(42))
nim --experimental c thing.nim
thing.nim(6, 8) Error: undeclared identifier: 'baz'
nim --version
Nim Compiler Version 0.14.3 (2016-08-09) [Linux: amd64]
Copyright (c) 2006-2016 by Andreas Rumpf
git hash: 5d05ee21c217e3585bf2eec9158e7aff8236894b
active boot switches: -d:release
This compiles and produces the right output for me:
type Bar = object
baz: int
{.this: self.}
proc foo(self: Bar) =
echo(baz)
foo(Bar(baz: 42))
But I know Nim's syntax and don't have weird Unicode whitespace in my file. ;-)
But I know Nim's syntax and don't have weird Unicode whitespace in my file. ;)
Well that was... vaguely insulting? I'm pretty sure the only whitespace in my file is ASCII space (0x20) and newline (0xa). Am I missing something here?
Alright, no problem. Oh. Oh god you were right to insult me though.
proc foo(self: Bar) =
I make that mistake all the time and I never see it. :(
You could've just pasted only that line! :p
Since I also already had once problems with weird unicode in my source by wildly copy pasting from pdf documents, I would really appreachiate a nice error message about illegal unicode characters. Non ascii whitespace and symbols should be illegal outside of string literals.
The only unicode symbols that I personally think are reasonable to accept would be the following:
It would allow a consistent nim source code where every operator consists only of symbols. But that's for another topic.