Jump to content

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
  • You cannot start a new topic
  • This topic is locked

0 < Myint < 2 Rate Topic: -----

#1 User is offline   temhawk 

  • W.R. Private First-Class
  • Group: Members
  • Posts: 322
  • Joined: 30-August 07
  • Gender:Male
  • Interests:travel, cg art, macs, music, skateboarding, programming, discovery channel, TextMate 2

Posted 04 December 2010 - 01:23 PM

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

#2 User is offline   Catalyst 

  • Codesmith
  • Group: Administrators
  • Posts: 1,049
  • Joined: 04-April 06
  • Gender:Male
  • Location:San Diego

Posted 05 December 2010 - 12:57 AM

Python, Perl 6, and Mathematica support chained operators
0

#3 User is offline   temhawk 

  • W.R. Private First-Class
  • Group: Members
  • Posts: 322
  • Joined: 30-August 07
  • Gender:Male
  • Interests:travel, cg art, macs, music, skateboarding, programming, discovery channel, TextMate 2

Posted 05 December 2010 - 06:48 AM

Cool.. I have been wanting to play around with some Python.. not the reptile! :blush: (very bad pun, i know)

I found the page I read, about modifying the built-in operators, and it's not JavaScript, but Ruby. :rolleyes: 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.
0

#4 User is offline   Catalyst 

  • Codesmith
  • Group: Administrators
  • Posts: 1,049
  • Joined: 04-April 06
  • Gender:Male
  • Location:San Diego

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.
0

#5 User is offline   temhawk 

  • W.R. Private First-Class
  • Group: Members
  • Posts: 322
  • Joined: 30-August 07
  • Gender:Male
  • Interests:travel, cg art, macs, music, skateboarding, programming, discovery channel, TextMate 2

Posted 05 December 2010 - 09:03 PM

Thanks Catalyst, and I do use a between() function already in most cases :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users