Verbosity of `this`
I want to enforce the use of this. in methods, but I recognize that it's very much a burden to type it out all the time.
However, Ruby has as a similar syntactical approach, the @ sign - which, when I used it in Coffeescript, I quite liked.
It's succinct, unique and easy for TextMate-based highlighters to show different colors for too.
// @Polygn
I think this could be handy... Would be easier to parse a single token @ rather than this as a string literal.
I haven't used CoffeeScript but I have seen it, so yeah, the usage of using a @ could be quite [as you put it] succinct.
Now a question on the actual syntax of using @ rather than this, would it be used (in Arua) like this:
@.foo
@.bar
or more around the lines of
@foo # C++ equivalent: this.foo
@bar # C++ equivalent: this.bar
@Polygn the second.
@Qix- perfect! That now makes it even faster for the compiler rather than having the period, less text.
But also less readable, I think.
If you're curious, all of the code I'm writing to test the lexer/parser is being pasted into a word document with no syntax highlighting - usually only done for things I'm not sure about (in terms of readability or maintainability). If it's not immediately obvious what it's doing, or if it requires a bunch of second looks, I am killing it.
This was the first thing I noticed. Look at it without syntax highlighting:
use math.*
on Foo be Bar
fn something(foo i32, bar i32, qux f32) f32
ret sin(bar as i32) * (6 * foo + @foo * bar * cos(foo as i32 * @qux) + qux) * 2
versus
use math.*
on Foo be Bar
fn something(foo i32, bar i32, qux f32) f32
ret sin(bar as i32) * (6 * foo + this.foo * bar * cos(foo as i32 * this.qux) + qux) * 2
I'm not sure which is more readable, but with syntax highlighting there's no mistake - this is much more readable since it'll be treated as a keyword.