Re: Type safety, C++ and code generation



Maciej Sobczak wrote:

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 is or can be problematic in those contexts where you
would rather expect them all to be different from each other -
especially when you think in terms of different *domains*, no matter
what is their range of values.

This is because "typdef" in C++ is "subtype" in Ada. You would need:

class R1 : ranged_type<int, 0, 100> {};
class R2 : ranged_type<int, 0, 100> {};
class R3 : ranged_type<int, 0, 101> {};

to create new types.

Martin
--
mailto://krischik@xxxxxxxxxxxxxxxxxxxxx
Ada programming at: http://ada.krischik.com
.



Relevant Pages

  • Re: Dynamically tagged expression required
    ... Maciej Sobczak wrote: ... >> compiler likely to use a pointer to pass the paramer to speed up things. ... Ada programming at: http://ada.krischik.com ...
    (comp.lang.ada)
  • Re: any regex gurus out there?
    ... > No matter what number or combination of backslashes I used it didn't work. ... - The compiler wouldn't take it otherwise. ... or escape each backslash with a backslash, ... > French language, the letter A may have three different accents. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Comparison to Comparison
    ... alive", no matter how long you wait after the Collect call, and no ... regardless of the size of the array. ... As near as I can tell, the issue is that when you assign into the objectas part of the argument to the WeakReference constructor, the compiler generates a hidden local variable. ... But, absent a more invasive inspection of the execution of the code, I'd admit that even your code example isn't proof of that. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C Programmer Needed
    ... >> For that matter, there isn't much from C99 that I miss. ... only thing either does is assert a guarantee that the program does not ... compiler vendors that matter a long time ago. ...
    (comp.programming)
  • Re: object system...
    ... ceases to matter, or at least until more code needs to be built around it.. ... for a compiler the program is a text. ... optimizations the ... No index range check here is necessary, because the compiler knows that I ...
    (comp.object)