You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today there is no way to allow parametrization of array lengths in types other than using constant declarations like so
constN=100// Parametrization defined at package level.typeRingBufferstruct {
off, endintbuf [N]byte
}
Drawbacks
Poor parametrization for module users: Note the length of the array is defined at a package level and when the type is exported it cannot be changed by end user other than using build tags which must be defined beforehand by module provider.
Poor reusability: Even if parametrization is allowed it can only be specialized once per compile. Regardless of build tag customization you need to create a new type for each array length desired. You also need to rewrite each method from scratch.
Proposal
Add possibility of array length type parametrization.
I use Go in embedded systems with TinyGo. My concern is memory usage regarding constraint on size and GC overhead and memory fragmentation. I'm currently writing a networking stack which can run on 100kB of RAM. I regularly make use of arrays to avoid heap allocations which are costly and they also fragment memory on these small devices. This feature would help the embedded scene a bunch for writing low level drivers :)
Below are links to OSI layers I have implemented in TinyGo.
Proposal Details
Context
Today there is no way to allow parametrization of array lengths in types other than using constant declarations like so
Drawbacks
Poor parametrization for module users: Note the length of the array is defined at a package level and when the type is exported it cannot be changed by end user other than using build tags which must be defined beforehand by module provider.
Poor reusability: Even if parametrization is allowed it can only be specialized once per compile. Regardless of build tag customization you need to create a new type for each array length desired. You also need to rewrite each method from scratch.
Proposal
Add possibility of array length type parametrization.
Example (demonstrative purposes only):
Author's note (more context)
I use Go in embedded systems with TinyGo. My concern is memory usage regarding constraint on size and GC overhead and memory fragmentation. I'm currently writing a networking stack which can run on 100kB of RAM. I regularly make use of arrays to avoid heap allocations which are costly and they also fragment memory on these small devices. This feature would help the embedded scene a bunch for writing low level drivers :)
Below are links to OSI layers I have implemented in TinyGo.
The text was updated successfully, but these errors were encountered: