Go's package-level variables are also not "globals". And you can control 
access with exported/unexported names or exported/unexported package-level 
functions.

PS: In Java everything is "class".


четверг, 17 января 2019 г., 23:31:34 UTC+3 пользователь robert engels 
написал:
>
> Java does not have “global” variables. All data access is via a Class, and 
> then possibly and instance of a Class. Contrast this with “globals” in C - 
> the variable - if declared external is visible to all code anywhere (there 
> are more modern ways to namespace this for some level of protection). 
>
> When declaring a ThreadLocal in Java, it still must be accessed using the 
> Class or instance accessor, which also means, since you can control 
> private/protected/package level access, you can prevent 
> unauthorized/uncontrolled mutation - this is completely different than 
> historical "globals” and the problems surrounding them. 
>
> > On Jan 17, 2019, at 2:19 PM, Ian Denhardt <i...@zenhack.net 
> <javascript:>> wrote: 
> > 
> >> They are not global variables, they are class variables. There's a 
> >> huge difference. 
> > 
> > Can you elaborate? I don't see a meaningful difference vs. Go's 
> > package-level var. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "golang-nuts" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to golang-nuts...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to