|
|
Subscribe / Log in / New account

Overloading

Overloading

Posted Apr 26, 2014 13:57 UTC (Sat) by aggelos (subscriber, #41752)
In reply to: Overloading by rsidd
Parent article: Porting the Go compiler to Go

The other extreme is OCaml which has different operators for integer and floating-point arithmetic. Now that makes code harder to read, or write.
Actually, I've found that to be quite helpful when writing code and I don't think +. (floating point addition operator in OCaml) is any harder to read than + (integer addition). Same for lack of automatic integer type promotions (wish I could opt out of that in some C code). I don't doubt there's programs where the extra type conversion calls would get in the way, but for most of the programs I write these days, it's nice when the type system discourages sloppy thinking about arithmetic. YMMV :-)


to post comments

Overloading

Posted Apr 26, 2014 14:34 UTC (Sat) by rsidd (subscriber, #2582) [Link]

Indeed, my mileage varies -- it's one reason I quit ocaml after writing one very serious program in it (with a published paper associated). Note that it's not just floats: you need to define new operators for bignums, complex numbers, matrices, and anything else that you may need to deal with. I still like other aspects of ocaml though. Maybe I should look at F# more seriously.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds