Prototype of Ownership/Borrowing System for D
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Nov 22 07:40:30 UTC 2019
On Friday, 22 November 2019 at 06:43:01 UTC, mipri wrote:
> I've never used TypeScript, but Kotlin's handling of nullable
> types
> is nice to the point I'd rather use the billion dollar mistake
> than
> an optional type.
Kotlin has type inference, but TypeScripts has to be able to
describe existing JavaScript data-models, so that it can provide
stricter typing from existing JavaScript libraries. As a
consequence TypeScript has to allow "crazy" mixing of types. Thus
a function can have parameters and a return type that is a union
of "incompatible" types. To make this work it fully embraces
flow-typing, that is: the type is determined by all possible
execution paths within a function. Thus TypeScript has many
features to deal with "undefined" (unitialized or non-existing
variable) and "null" (missing object) as you have to deal with
those from JavaScript code. And of course, this becomes a very
valuable tool when transitioning code to TypeScript from
JavaScript, or from a prototype to production code.
The verification language Whiley is following the same core
flow-typing principle, but since the type system of Whiley
employs a SMT engine it has more potential than TypeScript IMO.
See page 8 in
http://whiley.org/download/GettingStartedWithWhiley.pdf . (I
don't think it is production ready, but interesting nevertheless).
More information about the Digitalmars-d
mailing list