Re:Please put units in names
by svnpenn on Tuesday March 22, 2022 @12:14AM
(#30762672)
I'm sorry, but I just don't think people use code like you're describing. In your mind, you see this:
But people actually use code like this:
People working with Go code (who know what they're doing), don't declare an int, only to immediately cast it to something else.
[ Parent
| on HN ]
Re:Please put units in names
by chrismorgan on Tuesday March 22, 2022 @05:53AM
(#30764322)
You’re looking at this from the application perspective, where with the specific example of durations constant multiplication is certainly far, far more common. But you’re discounting library concerns, where it would not be out of the ordinary to receive a time.Duration and an int64 from parameters or a struct or similar.
This is also pretty typical of the trade-offs Go makes: it focuses on making things nice for the application writer, mostly pretty successfully, but at the regular cost of pain and with serious typing compromises for the library writer.