g77 future / proposed extension

Jamie Lokier jamie.lokier@cern.ch
Tue Feb 1 16:33:00 GMT 2000


Grant Petty wrote:
> Clearly, other languages could benefit from this as well, and some (such
> as C++) might even be able to accommodate my ideas without actually
> extending the language itself.

Yes, it has been done in C++.  I implemented that sort of thing twice in
C++.  It's very nice to use.

As a bonus, you can mess around with the representations for different
units, using the fastest and most compact integer representation when
you know your program doesn't need to deal with distances more
accurately than 1mm for example.

And you can do wraparound units, like `Angle' and `Direction'.

Vector units like `Distance', `Velocity', `Position'.

Relative and absolute units like `Time_Delay' and `Timestamp'.

By having a set of units like that, you can easily see the dimensional
correctness of your code.  And you clearly see the places where the code
is working in unusual numerical ranges, becuase it uses weird units there.

To finish, you can do all that while keeping the underlying units
abstract.  That's why I was able to optimise by using integer
representations for some things (this was in a video game): I could
select the units, and all the code using these abstract units, which was
quite a lot, just carried on working.

have a nice day,
-- Jamie


More information about the Gcc mailing list