🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Exponent Operator
Possible? Sure...
But when you consider the fact that the majority of the operators on built in types operate in constant time , a power operator, which not have a constant running time (except for some types), really doesn't make any sense.
Not to mention readability, the ^ operator is about the only one i would recognize as a power operator, ** would just be plain confusing. But if you're interoperating between C++ and AngleScript, ^ could become confusing very quickly. Something that won't happen with pow(x, y).
But when you consider the fact that the majority of the operators on built in types operate in constant time , a power operator, which not have a constant running time (except for some types), really doesn't make any sense.
Not to mention readability, the ^ operator is about the only one i would recognize as a power operator, ** would just be plain confusing. But if you're interoperating between C++ and AngleScript, ^ could become confusing very quickly. Something that won't happen with pow(x, y).
I agree with you Washu.
The ^ operator is already taken, otherwise that would be the ideal one for the power-of operation. ** have been used by other languages, and can be used in AngelScript, but it might confuse C/C++ programmer (a large part of the AngelScript users). Also a power-of operator isn't used very often thus it's not too much to ask to make the programmer call a function instead.
The case where the power-of operator is used the most is for the base 2, in which case the << (shift left) operator works just as well, if not better.
I don't think I'll implement the power-of operator unless someone can come up with a really good reason for it.
The ^ operator is already taken, otherwise that would be the ideal one for the power-of operation. ** have been used by other languages, and can be used in AngelScript, but it might confuse C/C++ programmer (a large part of the AngelScript users). Also a power-of operator isn't used very often thus it's not too much to ask to make the programmer call a function instead.
The case where the power-of operator is used the most is for the base 2, in which case the << (shift left) operator works just as well, if not better.
I don't think I'll implement the power-of operator unless someone can come up with a really good reason for it.
Quote: Original post by WitchLord
I don't think I'll implement the power-of operator unless someone can come up with a really good reason for it.
Go ahead and implement arbitrary user-defined infix operators. [grin]
banana(x,y) pales in front of x banana y.
That would be an option, except that it reserves keywords that might be used in other locations.
Oh yeah. I completely spaced that.
I didnt see the ^ in the list of operators, i must have just missed it.
And Washu, Multiplication is not constant time. It is repeated addition, and while it may be *fast* it is not constant time.
I brought this up because I have been converting a LUA script to AS and there is used a lot the ^ operator for powers.
Something like this: x pow 1456 is easier in my opinion to code than pow(x, 1456)
The only reason i proposed the operator was because in my initial skimming i did not see it currently being used.
I didnt see the ^ in the list of operators, i must have just missed it.
And Washu, Multiplication is not constant time. It is repeated addition, and while it may be *fast* it is not constant time.
I brought this up because I have been converting a LUA script to AS and there is used a lot the ^ operator for powers.
Something like this: x pow 1456 is easier in my opinion to code than pow(x, 1456)
The only reason i proposed the operator was because in my initial skimming i did not see it currently being used.
Quote: Original post by Rain Dog
Something like this: x pow 1456 is easier in my opinion to code than pow(x, 1456)
My mention of arbitrary infix operators was a joke. They're not fun to implement. And pow(x,1456) will be more familiar to most than x pow 1456...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement