dlang vs crystal-language
sighoya
sighoya at gmail.com
Fri Apr 30 13:41:48 UTC 2021
On Thursday, 29 April 2021 at 22:47:08 UTC, Alain De Vos wrote:
> What is the importance of type-annotations in which cases.
Specifying invariants which becomes very important when
refactoring code.
Further it aids as documentation to understand the structures
behind.
> @X @Y @Z makes code sometimes unreadable.
You mean something like `List!(HashMap!(String,T))`, yes, but I
like it in productive code.
It's often the case that verbosity becomes a plus in productive
software development, as more people have to read code that to
write it, a reason why Java is so successful
> Sometimes there is a good reason
Mostly for prototyping and obvious cases. But the most important
point of that is to write faster, I wish the IDE would help for
this instead of the compiler's inference.
I even think D doesn't even profit very well for inferred types,
you need anyway to specify auto which only saves work for large
type(application)s.
But when they are large, you probably want to prefer annotating
the type for the variable.
Instead, I want to point to some interesting solution C# offers
to save typing and also being explicit about the type:
https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/#target-typed-new-expressions
In fact, one could imagine that they overload the new operator
(at compiler level) to infer the type from the call site type
annotation.
More information about the Digitalmars-d-learn
mailing list