Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?

Submission Summary: 0 pending, 1 declined, 0 accepted (1 total, 0.00% accepted)

Trust the World's Fastest VPN with Your Internet Security & Freedom - A Lifetime Subscription of PureVPN at 88% off. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. ×

Submission + - Should PHP have Operator Overloading ?

garett_spencley writes: "I recently began the design phase on a new, rather large, project and am taking an object oriented approach. I considered using Java or C++ but have decided to chose PHP due largely to the amount of features built-in that I would otherwise have to implement myself or find 3rd party libraries for.

This project will implement several APIs and one thing that I would like to build into the design of those APIs is type enforcement. PHP has type hinting but only for classes and arrays. In order to strongly type a variable you have to use functions like is*() and settype() etc. and throw your own errors throughout all of your code. It would be ideal if I could create classes for various types and use operator overloading to perform operations without having to use methods or do a lot of type checking that might be forgotten, done incorrectly and, at the very least, clutter up the code.

Upon doing some reading it seems that there is very strong opposition from the PHP developers to include operator overloading in any near future version. From the Zend website:

"Jason Greene was interested in seeing the engine adopt some form of operator overloading. Both Andrei Zmievski and Zeev Suraski agreed that although this feature might have a chance at being useful, it would very likely make things far too complex. At this stage, it is highly doubtful Operator overloading will make it into the second version of the engine — if ever."

So my question is: what does Slashdot think ? Would PHP benefit from operator overloading or would it "make things far too complex" ?"

Slashdot Top Deals

"There is no statute of limitations on stupidity." -- Randomly produced by a computer program called Markov3.