Variable and function Groups


Hey guys, I was thinking why not have something in the language design that helps us with code organization and not affect the memory any how ?

I mean if we use the
val group = object { val myInt = 5 }

We are , AFAIK, creating an instance of an anonymous Class having an integer inside of it.

However if we had something that purely affects the code and gets cleaned up on compilation, it would be really great !
lets say something like:
codegroup group { val myInt = 5 }
And accessed like:
val someNewInt = group.myInt + 10
And after compilation the variable myInt will look like group_myInt for example


it’s hard for me understand your use case, moreover it’s harder to quantify benefits.

Currently Hotspot and GC do a lot of great work for improve performance, like preserve data locality and stack allocation(*) (yes, the myth of Valhalla is only a further improvement).

In a memory managed runtime avoid to fix any unproven memory problem: may be only a premature optimization.