3 ms·
One small note, but Nim's comptime support is on par with Zig's. It's preferred using comptime and templates over macros when possible. Here's an example (1) o
by elcritch 4y ago
One small note, but Nim's comptime support is on par with Zig's. It's preferred using comptime and templates over macros when possible.
Here's an example (1) of a compile time object to key value layer I did without macros. It's a basic wrapper to split an object's fields into separate key-value pairs for storage. The problem is that the storage system only has 16bit ints for keys which makes collision a large possibility. So this wrapper checks at compile time that there aren't duplicate keys.
1: https://github.com/EmbeddedNim/nephyr/blob/main/src/nephyr/extras/nvsConfigObj.nim https://github.com/EmbeddedNim/nephyr/blob/main/src/nephyr/e...