Closed TheCodedOne closed 2 years ago
What you are suggesting is basically a subest of the feature suggested in #52 .
That would be a relatively safe way to create expressions of optimal length. Automatically splitting large expressions into smaller once, would be an alternative, but could result in a lot of unexpected timing-behaviour. Having large expressions defined as multiple small assignments, which are then combined into a minimal amount of expressions seems much safer.
The only hard part about this is, that merging the assignments must be postponed until it is known how much space is left on the previous line, so that it results in the maximum code-density.
I think that might even be possible without a type-system.
In an effort to clean up a little, I am closing this as a duplicate of #52
Is your feature request related to a problem? Please describe. When doing additive assignment it compiles to something needlessly long sometimes
Describe the solution you'd like compiler could automatically figure out a simpler addition format
compiles to
realistically could be turned into
or further into
Additional context It's probably reliant on the type system (#48) for it to be able to work correctly.
It's also a very weird case, there's always the option of just manually making sure your additions are as optimised as they can be, which is obviously the preferred way anyway, however depending on the complexity of implementation could be worth the potential for optimisations