Sorry. I know I have asked this before but I cannot find the answer.
Thanks - Damian
Sorry. I know I have asked this before but I cannot find the answer.
Thanks - Damian
Hi Damian —
I think of these as being near-equivalent, in the sense that they are both generic, albeit using slightly different approaches ("any real" vs. "any type as long as that type is a real"). They also have (likely obvious) different naming impacts (the former will give you a param w
that's the real
's bitwidth; the latter gives you a type alias R
representing the specific real
type).
Of the two, I find the former to be the preferable form because it states the intention in a clearer and more up-front way, whereas using the where clause for a case like this feels like more of an afterthought / late specification of a constraint (where again, I read it as "This can be any type, but only if that type is a real
" which feels a bit roundabout to me).
-Brad