The thing is, using `cast` is usually not what you want. To quote [the 
manual](https://nim-lang.org/docs/manual.html#statements-and-expressions-type-casts):

> Type casts are a crude mechanism to interpret the bit pattern of an 
> expression as if it would be of another type. Type casts are only needed for 
> low-level programming and are inherently unsafe.

It is _much_ more likely that someone would want to use a conversion, like 
`float(1234)`.

If you _do_ need to interpret the same bits as a different type (for which 
there are indeed valid use cases), I would argue that it's much better to be 
explicit about this. I also think that the slightly ugly syntax matches the 
fact that the whole idea of what's happening here is slightly ugly in itself.

Of course, your own projects are your own business, but it would be my 
recommendation to avoid creating weird constructs like this. It makes it harder 
to read for the next person who comes along trying to learn your code. I would 
especially advise against it if you're doing something open source.

Reply via email to