I wonder if any programming languages allow you to write an expression like the one in the title. I tried it in JavaScript, but it didn't work (didn't cause a syntax error either). I think having a feature like that would be awesome. If you know of any programming languages that do this, please let me know!
P.S. I read a while ago that the built-in operators (of JavaScript, I think) themselves can be modified. That makes me think if it might be possible to add the behavior myself... although it could be a lot of work if it is possible.
0 < Myint < 2
Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.
Page 1 of 1
0 < Myint < 2
#2
Posted 05 December 2010 - 12:57 AM
Python, Perl 6, and Mathematica support chained operators
#3
Posted 05 December 2010 - 06:48 AM
Cool.. I have been wanting to play around with some Python.. not the reptile!
(very bad pun, i know)
I found the page I read, about modifying the built-in operators, and it's not JavaScript, but Ruby.
Also a nice programing language, but I am just a big newbie with it.. I wish I had the time to do more stuff with it.
Now Perl and Mathematica... I don't think I will be touching them any time soon! I just hope that JS and PHP will get chained operators like that in the not too distant future. That would be cool.
I found the page I read, about modifying the built-in operators, and it's not JavaScript, but Ruby.
Now Perl and Mathematica... I don't think I will be touching them any time soon! I just hope that JS and PHP will get chained operators like that in the not too distant future. That would be cool.
#4
Posted 05 December 2010 - 06:10 PM
From what I've read it's difficult for language parsers to work with chained operators, so I don't think you'll find it popping up in other languages any time soon. Especially since you can do the same thing with only a few more characters. Operator overloading is common enough, like you mentioned, but you won't be able to get it to do what you're trying. Now, you could easily write a function like x.BETWEEN( a,b ) or BETWEEN( a,x,b ) that'd return a bool and use that in your comparisons.
#5
Posted 05 December 2010 - 09:03 PM
Thanks Catalyst, and I do use a between() function already in most cases
Share this topic:
Page 1 of 1


Help
This topic is locked

MultiQuote









