What's New in C# 13: Enhanced Params, Performance Boosts and New Extension Types
infoq.com
infoq.com
It allows domain-specific types. So instead of a function like getCustomer(int customerId), you could write getCustomer(CustomerId customerId) which is an integer (no extra memory allocated - it's a struct wrapper).
This is similar to the feature I use in typescript with zod z.brand('customerId') which adds a compile-time only hidden explicit type.
The really cool thing about this is that we can then enforce a rule that says CustomerId can only be, for example, a positive integer. Or that a string matches a given regex. We're validating a type and passing it around without wrapping it. You can still treat it as a primitive but you cannot treat the primitive as it without validation.
In other words, it can be thought of as ada's more strict types. e.g. type customerId range 1 .. 1000
Orientating validation around the type and not the function means that you only validate once yet are completely confident about it everywhere. We can essentially replace a lot of unit tests with a better type system.
Validated types are almost as a big of leap as types at all. They are descriptive, prevent a large class of bugs, while staying intuitive - not magical.
Being able to write a function/procedure and know that the parameters could only be within a certain set of legal values by that point let you avoid a lot of defensive coding, without having to rely on developers remembering to check their values.
If you got your values into domain specific subtypes as early as possible your code was so much easier to reason about. It made a lot of the static analysis easier as well.
[0]: https://news.ycombinator.com/item?id=40470193 [1]: https://news.ycombinator.com/item?id=40500499 [2]: https://news.ycombinator.com/item?id=40509169
The naming of "params parameters" sounds like C++ "template template" parameters.
The list used to always be an Array, but now it will be possible to have it as any collection type (including IEnumerable<T>).
https://stackoverflow.com/questions/69977898/where-is-link-t...
Which is why a certain K-language is not an option for me. Sadly, since as a language I would much prefer it.