|
|
|
|
|
by jnbiche
3549 days ago
|
|
As someone pointed out elsewhere, Pascal's discriminated variants ("variant records") aren't typesafe, since the tag isn't checked before the variant is accessed. From Essential Pascal, 4th edition: "The use of a variant record type is not type-safe." The whole point of the article's discriminated unions/records in Rust and C++17 is type safety. Maybe this has been built into one of the newer Pascal descendants, but it hasn't been around for years and years. And embedded C programmers have been using these kinds of "unsafe" discriminated unions for years. That said, I do think Ada has had these kinds of actually typesafe variant records for quite a while. But again, Rust isn't making any claims to innovation. Even the language name ("Rust"), is a reference to the language being based on rusty old best practices. |
|