Closed kerams closed 4 years ago
Thank you for the suggestion kerams!
Using units of measure would definitely take advantage of a unique F# feature. It's lightweight in the sense that it only affects compile-time checking and would be indistinguishable from using int32 at runtime.
I haven't done any benchmarks to measure the difference between using int32 directly and using it wrapped in a struct. I'd be curious to know if there are significant differences.
Both 'Eid 1' and '1
One UoM downside is that anyone using the library from C# wouldn't have the benefit of strong typing since it would appear as int32. So far I haven't made C#-friendliness a priority, but I also don't want to exclude it unnecessarily.
That about C# is a fair point.
Hello, have you considered defining a unit of measure for
Eid
instead of the struct? It would be just as type-safe with the added bonus of a smaller footprint (though hardly a game changer).Something like
Reimplementing the
Eid
module could be a bit inconvenient because of all the bit operations where you'd have to strip the UoM and then reapply it.