Re: Type safety, C++ and code generation




"Maciej Sobczak" <no.spam@xxxxxxxxxxx> wrote in message
news:e2qn8t$n13$1@xxxxxxxxxxxxxxxxxx

What about making different types really distinct?

typedef ranged_type<int, 0, 100> R1;
typedef ranged_type<int, 0, 100> R2;
typedef ranged_type<int, 0, 101> R3;


Above, R1 and R2 are *equal* to the compiler, but R3 is distinct from the
other two.
This example raises the issue of structural equivalence versus
name equivalence. In Ada R1 and R2 would not be
equivalent.

Ada is designed for name equivalence. Most other languages
are designed for structural equivalence. In this respect, Ada
continues to be just a wee bit more type safe than languages
designed for structural equivalence.

Richard Riehle


.



Relevant Pages

  • Re: Type safety, C++ and code generation
    ... This example raises the issue of structural equivalence versus ... Ada is designed for name equivalence. ... continues to be just a wee bit more type safe than languages ... or union. ...
    (comp.lang.ada)
  • Re: Certified C compilers for safety-critical embedded systems
    ... Ada requires the function return type to match the array index type. ... This is invalid because the function beauty_index always returns ... For Ada this structural equivalence is meaningless. ...
    (comp.arch.embedded)
  • Re: Looking for a new language
    ... > Basically I am boiling down to a choice of 3 languages. ... Python ... You should also consider Ada. ... Richard Riehle ...
    (comp.programming)