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
Now that #11188 has made integer overflow an error instead of undefined behavior (which would manifest itself as just wrapping around), performing operations on IP and MAC addresses has become much more difficult. Additionally, until #11188, it had to be performed using an incredibly slow pure Nix implementation, which would make any non-trivial usage of such operations easily dominate the evaluation time of a NixOS configuration (e.g. #10387)
Proposed solution
Implement more built-ins for bit manipulation, including left and right shifts. This can be implemented quite easily; e.g. this Lix patch is quite small, with about half of lines of code changed just being documentation and makefile updates.
Implement a power function built-in. This would be very slightly trickier (but still trivial) due to checking whether the arguments are ints or floats. Ideally, it would also include a modulo argument.
Alternative solutions
One alternative to work around the specific issues in the linked issues/PRs would be to implement arbitrary-sized integers, e.g. by using the GNU MP library; but an ideal implementation of this would end up exposing the aforementioned built-ins anyway.
Uh oh!
There was an error while loading. Please reload this page.
Is your feature request related to a problem?
Now that #11188 has made integer overflow an error instead of undefined behavior (which would manifest itself as just wrapping around), performing operations on IP and MAC addresses has become much more difficult. Additionally, until #11188, it had to be performed using an incredibly slow pure Nix implementation, which would make any non-trivial usage of such operations easily dominate the evaluation time of a NixOS configuration (e.g. #10387)
Proposed solution
Implement more built-ins for bit manipulation, including left and right shifts. This can be implemented quite easily; e.g. this Lix patch is quite small, with about half of lines of code changed just being documentation and makefile updates.
Implement a power function built-in. This would be very slightly trickier (but still trivial) due to checking whether the arguments are ints or floats. Ideally, it would also include a modulo argument.
Alternative solutions
One alternative to work around the specific issues in the linked issues/PRs would be to implement arbitrary-sized integers, e.g. by using the GNU MP library; but an ideal implementation of this would end up exposing the aforementioned built-ins anyway.
Additional context
Checklist
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: