[.net] Typedef or something similar?

Started by
13 comments, last by Nypyren 18 years, 8 months ago
the numerous ints and floats are the point ...

such as:

rank, value, degreesInCelcius, degreesInFerenheit, ...

they serve to partition of incompatible values into seperate names ... which allows very cool options such as later writing the usefull ones as classes - and getting errors on incompatible usages, and conversion on compatible uses.
Advertisement
Quote:Original post by Xai
the numerous ints and floats are the point ...

such as:

rank, value, degreesInCelcius, degreesInFerenheit, ...

they serve to partition of incompatible values into seperate names ... which allows very cool options such as later writing the usefull ones as classes - and getting errors on incompatible usages, and conversion on compatible uses.


Since when did C++'s typedef allow that?

[Edited by - Daniel Miller on August 5, 2005 11:36:51 AM]
C++ typedefs allow the changing of the type, by the changing of the def ...

I can go into SomeType.h which has: typedef int SomeType;

and change the file to be a full fledged class declaration ... whenever I want to, as long as the contract I have promised the client isn't violated ...

if the user had just used "int" instead of "SomeType" then I would have that ability ...

so in C++'s typedefs, you cannot automatically convert celcius to farenheit WHILE they are still typedefs ... but you can refactor them into classes later, and gain that feature ...

and if you've ever worked on a mid sized program with a lot of number crunching, you should realize how hard it is to go in and change JUST THE RIGHT floats to doubles - when they decide the space physics need to become doubles - but the ground physics is still floats for efficiency ... if they didn't use typedefs, you'd be hosed.
I agree with mutex. I'm so sick of working with other people's projects where they typedef the freaking basic types even when there's no chance in the world that any of their code will be ported to a different system where it might matter.

Real life quote:

Me: "float32? ... and they use double over here. Consistency rules!"
Quote:Original post by Xai
you should realize how hard it is to go in and change JUST THE RIGHT floats to doubles - when they decide the space physics need to become doubles - but the ground physics is still floats for efficiency ... if they didn't use typedefs, you'd be hosed.


That assumes you have separate typedefs for your space and ground physics models. If you used the same typedefs for both systems from the start (float32), you're still hosed :(

This topic is closed to new replies.

Advertisement