Which language constructs could be done as a library if we accept some breaking changes?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Nov 29 16:27:41 UTC 2021


On Monday, 29 November 2021 at 16:14:29 UTC, jmh530 wrote:
> Typescript's object types look to me like Go's interfaces 
> (which are like Rust's traits), but with a bit more 
> flexibility. They look more runtime-oriented than C++'s 
> concepts.

Hm. I think I understand what you mean, but TypeScripts type 
system does not exist at runtime at all, so it is static and for 
compile time only (or mostly). Runtime type checks are limited to 
JavaScript. Go is more dynamic in nature and therefore not fully 
static, so some typing errors will be discovered at runtime in Go.

TypeScripts types are however weak, in the sense that they are 
just painted over JavaScript objects that may have content that 
contradicts the types TypeScript paints over them. Kinda like how 
D can paint incompatible types over data-structures received from 
C code.

In that context maybe it would be interesting to have something 
similar, and allow programmers to «paint constraints» over both D 
and C data-structures to catch more bugs at compile time.






More information about the Digitalmars-d mailing list