Jump to content
  • Advertisement
  • entries
  • comments
  • views

Tangent: int sucks.

Sign in to follow this  


Work continues to be hellish. If someone does not go postal or quit or end up in a psych ward or shot by an angry client by the end of next week, we'll call it a win.

So no Tangent work. Still need to implement better method grouping for phrases, generic bits for phrases, the type-arg sort of stuff, and constraint inference. After that though, I'm considering making less ints.

Less ints you ask? Yes. Not the 4-byte, 8-byte, 16 byte, etc ints (though there should only really be big int, native int and compatibility), but something to promote not using ints everywhere. There was a post here where a beginner couldn't use trig functions because they failed to realize that it took radians. Any sort of physical modeling will use lengths and sizes; most should be in meters, but what if they're not? And why do they need to be specified in meters rather than km or cm for different models?

And the same sort of problem exists with time values (is that 4pm local or gmt?), with currencies (usd, ausd?)...

Sure, in languages that allow it, people could declare a type that acts like a number but is restricted explicitly to be n seconds or meters or goats. But nobody does, because it's either tedious and sucky or because it's too slow or because it causes problems when interacting with other stuff. And nobody will really implement them with any consistency. And you run into problems about ownership of the certain data. If you have 100 goats here and 200 goats there, does there need to be two instances of goat data? Can that be static?

So I think that it would be cool to make that not tedious so it fits into idiomatic Tangent. Something that is consistent and intuitive. A feature that gives enough benefits over annoyances that people actually use it rather than ints everywhere.

The key sort of thing I'm looking to gain is:

set AlarmClock to Now + 5 minutes;
AlarmClock = Now + 5 minutes;
// versus
set AlarmClock to Now.AddMinutes(5);
AlarmClock = Now.AddMinutes(5);

x = sin( 30 degrees ); // distinct types can be overloaded more cleanly
x = sin( 1.2 radians );

local meters distance = 30 cm; // via some auto-conversion table.

Ogre gains 50 strength; // can go into a container of stats rather than
// int strength;

There are a few problems that are looming about. Certain things should be just ints. Some are acceptable as floats. Some probably even more exotic numbers. Some make no sense as negatives... how to deal with that. How to deal with overloading. Tangent tends to allow people to re-use identifiers; overloading behaviors. Should the name of the label follow that or be kept distinct. How to deal with classifications of these things (having a currency type that can hold usds or euros). And perhaps most far-reaching is that the best way to implement this sort of thing is to make int a method that takes either a type param or an identifier and returns the new typed int. That may yield some unexpected results (or uuuuuugly misuse) in some scenarios.

Still, something I'm thinking about. Can't find anything at first glance regarding language support elsewhere for this sort of thing. I would've thought that it would've been tried or at least speculated. Probably the best line of thought would be to look at C++ and how the things would be implemented there; what the flaws or annoyances were. Y'know, if my google-fu continues to suck.

And hopefully time and motivation will return to get the 4-6 things ahead of this puppy on the list.
Sign in to follow this  


Recommended Comments

I once wrote a language (compiled to IL) that supported units of measure, you could define a unit and how it related to other units, it would then (at compile time) figure out statically the best conversion route between units. It also had the ability to handle function unit conversions, such as fahrenheit to celsius or visa versa if you provided the conversions.

Overall it was reasonably fun to develop, but in the end the language was pretty much useless as it didn't solve any real problems.

Share this comment

Link to comment
Hey I havent been around these forums much till recently so I havent been keeping on top of your language for a while.

Anyways you may wish to check out F# Units of Measurements. The guy who wrote it did his PhD in it.


Share this comment

Link to comment
Wow, thanks. That link is pretty much exactly what I was looking for!

Well, as far as research; the syntax and terseness is so-so. At least a very good example why that sort of setup is exceptionally beyond some C++ hackery.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!