waxwing on Nostr: For the Rustaceans out there, a question: I have a set of complex routines all ...
For the Rustaceans out there, a question: I have a set of complex routines all parameterized by a const value L (the 'branching factor' of the curve tree), and that L is used to size various arrays etc. So it's specified as a const generic. Now I want the user to set this value in a config file, because depending on how many pubkeys they're processing, different L values will be appropriate. Now, to be clear, only a few possible powers of 2 are probably ever needed for L (even as few as 3; 256,512,1024 probably covers most practical scenarios, though more values would be nice), but of course, setting it in a config is incompatible with compile-time specification, as a const. What's the most sensible solution? Writing multiple versions of the calling function so the config var can choose which one to run? If so, how to do that most cleanly (macros? how?), or if not, what is another smarter way to do it?
Published at
2024-03-29 17:05:08Event JSON
{
"id": "3330d4e51c715c8d168f1789463a0f414db764de518ea13772565524f05eb7f7",
"pubkey": "675b84fe75e216ab947c7438ee519ca7775376ddf05dadfba6278bd012e1d728",
"created_at": 1711731908,
"kind": 1,
"tags": [],
"content": "For the Rustaceans out there, a question: I have a set of complex routines all parameterized by a const value L (the 'branching factor' of the curve tree), and that L is used to size various arrays etc. So it's specified as a const generic. Now I want the user to set this value in a config file, because depending on how many pubkeys they're processing, different L values will be appropriate. Now, to be clear, only a few possible powers of 2 are probably ever needed for L (even as few as 3; 256,512,1024 probably covers most practical scenarios, though more values would be nice), but of course, setting it in a config is incompatible with compile-time specification, as a const. What's the most sensible solution? Writing multiple versions of the calling function so the config var can choose which one to run? If so, how to do that most cleanly (macros? how?), or if not, what is another smarter way to do it?",
"sig": "4030b90d558fca2566c52c1d1021c57b4444db44b00c4a781c7eb76067326c6a729288b813b2857b4fa8e0e8c2d303d1d8b04983131ce9634f5bd3ab323e32c2"
}