@ alias for self

Has any consideration been given to using @ (or another sigil) as an alias for self?

This is done in Ruby and a number of the JavaScript based languages offer it as a replacement for this.

That is, prod = self.a * self.b prod = @a * @b

are equivalent.

I often view sections of rust code where every line has one, two or three selfon it. This takes up significant horizontal space and creates visual clutter.

Using @ instead of self. is one character instead of five and still provides a readable, easily understood means of making member access explicit.

It would just add more weird sigils to a language that’s already notorious for being very sigil heavy. It would also go against the principle of “having only one way to do things”, and create confusion not only to those new and learning the language, but also make it harder to read another person’s code. (based on whether they use the same convention as you)

I wouldn't consider the @ symbol easily understood. It might make sense to Ruby programmers, but that's just Ruby programmers and the "target market" is systems programmers. Echoing @nightpool's concerns here: this is just another strange symbol where we could have an actually-meaningful word that is a bit less concise.

In the one class I took that used ruby, the distinction between @var and var caused the most confusion by far. Quite a few students just used @var everywhere without even realizing what it meant.

It wouldn’t make sense to a ruby programmer either, because @var is an instance variable. @ by itself means nothing.

Perhaps .foo?

prod = self.a * self.b
prod = .a * .b

I can see that having problems with long lines:

let a = some_big_func_that_uses_up_a_line()
    .bar()
    .baz();

Currently it's clear that .bar() is a continuation, and adding a semicolon anywhere in the statement will break the program. Now it's less clear.

Overall I'm a big -1 on this. It doesn't strike me as a big issue, and just makes the language more complicated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.