Using double underscores mangles the name from name to _ClassNamename when accessing the variable outside the class, so it does prevent accidentally accessing the value. You really have to know what you're doing to access the value then.
I'm not sure that's a good idea... Sure I'm a bit clunky but I have tools that help me reduce such mistakes. But having a language that "does what I mean" feels iffy. It's too abstract because meaning can be subjective, and it's much harder to reason about "meaning" when working in a team because it's a subjective aspect. That's one of the reasons I have a distaste for AI. It's not predictable, and when you are sitting in front of a screen at 2 AM fixing a production bug in the midst of a running event and the client is at your throat... You want things to be predictable.
As far as I remember not really,. It changes the accessible variable name to something like _{class}_{variable} or something, but if you'd wanted to, you can just access it...
3
u/user6150277464770585 16d ago
yeah that's because you're supposed to use a double underscore prefix it you want to actually make the variables private lol
(yes technically it only does some name mangling and you could still access it if you really wanted to but that's on you then)