Phil Roberts <ph*****@HOLYflatnetSHIT.net> wrote in message news:<Xn*************************@216.196.97.132>. ..
Type hinting in PHP5 only applies to objects anyway, and with the new
object model all objects are passed by reference. Default parameters
were only ever available to variables passed by value.
OK, I think I may have to further explain the point of my question.
Answer these simple questions:
1. Is there function overloading in PHP?
2. Why does PHP not need function overloading, like languages such as
Java do?
When you've done that you come to the conclusion that the workaround
for having no function overloading is default arguments. So far so
good...
...Until type hinting comes along, which, IMO, is a partially
implemented feature if it doesn't allow for hinting on optional
arguments. I think people are getting bogged down in syntax here...
saying things like "you can't have expressions in arguemnts
definitions." I really couldn't care less about having expressions in
argument defintions...
function someFunct(Type1 $arg1, Type2 $arg2 = new Type2()) { }
or
function someFunct(Type1 $arg1, Type2 $arg2 = Type2::getInstance()) {
}
....IS ugly, which is why there should be a new syntax for optional
(hinted) arguments in PHP5, such as:
function someFunc(Type1 $arg1, ? Type2 $arg2)
or
function someFunc(Type1 $arg1, [Type2 $arg2], [Type3 $arg3]) etc
etc...
Just to say "well that's the way it works" isn't very helpful, nor is
it informative.