Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualÁlvaro

Posted 23 May 2013 - 08:34 AM

Bacterius, on 23 May 2013 - 06:12, said:

rnlf, on 23 May 2013 - 04:04, said:
Ada does this. It's a nice safety rope but it can also get quite messy. Velocity equals acceleration times time? Nope, not without converting everything to a common base type. It is nice to know that you cannot mix different types by accident, but it also means you cannot mix them intentionally without writing more code.

Now I want to see a language that associates units with variables and intelligently checks that they remain valid throughout statements huh.png


C++ can do that. You can use a template class that has integer parameters indicating the power of kilogram, meter and second. All the class does is wrap a floating-point number. Now define operators that deal with types appropriately.

Or you can use Boost.Units.

EDIT: Fixed the link. This editor and I don't get along...

#4Álvaro

Posted 23 May 2013 - 08:34 AM

Bacterius, on 23 May 2013 - 06:12, said:

rnlf, on 23 May 2013 - 04:04, said:
Ada does this. It's a nice safety rope but it can also get quite messy. Velocity equals acceleration times time? Nope, not without converting everything to a common base type. It is nice to know that you cannot mix different types by accident, but it also means you cannot mix them intentionally without writing more code.

Now I want to see a language that associates units with variables and intelligently checks that they remain valid throughout statements huh.png


C++ can do that. You can use a template class that has integer parameters indicating the power of kilogram, meter and second. All the class does is wrap a floating-point number. Now define operators that deal with types appropriately.

Or you can use Boost.Units.

#3Álvaro

Posted 23 May 2013 - 06:15 AM

Bacterius, on 23 May 2013 - 06:12, said:


rnlf, on 23 May 2013 - 04:04, said:
Ada does this. It's a nice safety rope but it can also get quite messy. Velocity equals acceleration times time? Nope, not without converting everything to a common base type. It is nice to know that you cannot mix different types by accident, but it also means you cannot mix them intentionally without writing more code.


Now I want to see a language that associates units with variables and intelligently checks that they remain valid throughout statements huh.png

C++ can do that. You can use a template class that has integer parameters indicating the power of kilogram, meter and second. All the class does is wrap a floating-point number. Now define operators that deal with types appropriately.

Or you can use Boost.Units.

#2Álvaro

Posted 23 May 2013 - 06:15 AM

Bacterius, on 23 May 2013 - 06:12, said:


rnlf, on 23 May 2013 - 04:04, said:
Ada does this. It's a nice safety rope but it can also get quite messy. Velocity equals acceleration times time? Nope, not without converting everything to a common base type. It is nice to know that you cannot mix different types by accident, but it also means you cannot mix them intentionally without writing more code.


Now I want to see a language that associates units with variables and intelligently checks that they remain valid throughout statements huh.png

C++ can do that. You can use a template class that has integer parameters indicating the power of kilogram, meter and second. All the class does is wrap a floating-point number. Now define operators that deal with types appropriately.

Or you can use Boost.Units[/url].

#1Álvaro

Posted 23 May 2013 - 06:13 AM

Bacterius, on 23 May 2013 - 06:12, said:

rnlf, on 23 May 2013 - 04:04, said:
Ada does this. It's a nice safety rope but it can also get quite messy. Velocity equals acceleration times time? Nope, not without converting everything to a common base type. It is nice to know that you cannot mix different types by accident, but it also means you cannot mix them intentionally without writing more code.


Now I want to see a language that associates units with variables and intelligently checks that they remain valid throughout statements huh.png

C++ can do that. You can use a template class that has integer parameters indicating the power of kilogram, meter and second. All the class does is wrap a floating-point number. Now define operators that deal with types appropriately.

Or you can use [url="http://www.boost.org/doc/libs/1_53_0/doc/html/boost_units.html"]Boost.Units[/utl].

PARTNERS