News for hackers. Stuff that matters.
Re:Using 'this' incorrectly in C# by brundolf on Friday August 14, 2020 @11:14AM (#24158963)
I didn't know about static imports. Technically those are still member functions, but you are able to call them without a prefix, so I retract that point.

> So they do have non-member variables, in local variables. Making it clear that something is not a local variable is valuable as it means the variable has a much larger scope than you might expect.

Yes, local variables are non-member variables. I'm just pointing out that people's habits may have been built in JavaScript or the like, where a non-member variable could be:

- a global

- from a closure, anywhere up the tree

- an import from another file

Whether or not the explicitness is still important in C# code, it's at least much more important in JavaScript and Python code (in fact I'm pretty sure both languages require it)

Re:Using 'this' incorrectly in C# by masklinn on Friday August 14, 2020 @02:16PM (#24161333)
> Yes, local variables are non-member variables. I'm just pointing out that people's habits may have been built in JavaScript or the like, where a non-member variable could be:

> - a global

> - from a closure, anywhere up the tree

> - an import from another file

C# has "from a closure, anywhere up the tree" and "an import from an other file" though, the only thing it arguably doesn't have is "a global".

> Whether or not the explicitness is still important in C# code, it's at least much more important in JavaScript and Python code (in fact I'm pretty sure both languages require it)

Technically you can use the `with` statement to make it implicit in javascript.

You should not, but you can.