7 ms·
One feature F# has that would be great is that you can declare primitives as a a type. So you won't mix up your kilometer floats with your miles floats. And kil
by dep_b 10y ago
One feature F# has that would be great is that you can declare primitives as a a type. So you won't mix up your kilometer floats with your miles floats. And kilometers divided by hours ends up being a km/h value.
The other one we'll never see: Non null references as a default, optionals as a special case.
- amenghra 10y agoIn java world, there has been some discussion for something similar: https://jcp.org/en/jsr/detail?id=363 https://jcp.org/en/jsr/detail?id=363
- d--b 10y agoThey specifically avoided that in the early days of designing the language. Typedefs, macros, meta-programmation, overloading operators like () or -> are common in C++ but lead many people to completely change the language. So much so that there are C++ codebases that cant be read by standard C++ developers. The C# guys avoided that pit. As a C# developer I can read any codebase and know what's happening. That's not so true in F# where people are prompt to create their own operators (like ||>) and types.
- oblio 10y agoOperators, I get, but what's wrong with creating your own types?
- profquail 10y agoThe F# ||> operator is provided by the core library. Over-use of custom operators is something I always push back on in F# codebases; they can sometimes be useful in making code more expressive, but the downside is it makes the code significantly more difficult to comprehend until you're familiar with what each operator does. I prefer readability over concision, and even without the custom operators F# code is fairly terse.
- macca321 10y agoI'm hope it will come. In the meantime, you can always create a wrapper type, or use something like the ValueUtils nuget package.