On 16.10.2007, at 15:09, Hans Moog wrote:
When it comes to interoperation between systems and or developers,
it is always a
good idea to define strict standards of how the communication
between libarys and components
has to take place (since public methods are something like an
interface bewteen interoperating libraries and classes),
to be sure that all components work together as expected. One of
the best approaches to
explain the usage of the class to a foreign developer and to be
sure that your class is used
correctly and help the foreign developer to understand how your
classes have to be used
(beside documentation), is to typehint your parameters.
I do not agree that its always a good idea to make your communication
strict when you are using a type less language. Are you implying that
for some reason typeless-ness only becomes relevant in your user land
code? I do agree that libraries tend to be a bit more "static" and
therefore less in need of quickness in development, but I do not see
this validating your core assumption that strictness is a good thing
for libraries. PHP has always tended more towards keeping running
when at all possible rather than throwing fatal errors. The advent of
exceptions has changed part of this game already, but I do not think
that the solution is to start turning every situation the developer
hasnt thought off into fatal errors. Sometimes barely working is
better than not working and I think this is a mantra on the web.
But when you do so, you are no longer able to overload your methods
anymore. Because of this, I think
this feature is EXTREMELY relevant to solving the web problem. Not
being able to overload methods anymore
is a bad thing since overloaded methods allow to use a class in
much more situations than just being able to use it
in one single way.
You are not able to tell the developer to use integer OR string
values but NO arrays, booleans, Objects
and so on when calling your method.
You could mention it in the comment but when he misunderstands the
comment, php doesn't notify him about
his error. When using type hinted parameters, php would do so.
You are not able to provide strict api's out of the box right now.
You will always have to check the types of the
passed parameters manually.
Your list of if's is quote long, which illustrates what kind of niche
problem you are solving. The bulk of all libraries can live quite
well without type hints. If you choose to use them, then accept their
limitations and add manual overloading via separate functions that
cover all reasonable permutations. Or implement this overloading the
same way other people handle the lack of named parameters. The
addition of type hinting was questionable enough, that they hardly
warrant yet another addition just to make them even more useful in a
niche case.
regards,
Lukas
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php