On 11 August 2010 08:23, Stas Malyshev <smalys...@sugarcrm.com> wrote:

>> I very much can, it's just not my intention. I want to be able to use
>> type hinting/type checking as a sanity check. If I write a method
>> whose signature is foo(int $n) I signal my intention to only accept
>
> Then you should use statically typed language.

Yeah, hmm, no, and it is disingenuous of you to equate type hints to
PHP becoming statically typed. I'm sure that some people would love to
have optional static typing in parts of their code, but I like being
able to use my vars freely when I need to. Being able to enforce what
type of arguments can be passed to my functions and methods would
allow me to cut down on my parameters validation. Similarly, I like
using protected methods to prevent users [developers using the code]
from misusing them or protected properties to prevent users from
inadvertently modifying them, so that I don't have to worry about the
application being in an inconsistent state.

PHP being dynamically typed shouldn't be an argument to prevent people
from enforcing method signatures. You're saying that PHP users should
have no control over what variable types are passed to their
functions.

>> If PHP was meant to prevent programmers from controlling the type of
>> their variables then I'm afraid there's been a misunderstanding and
>
> PHP and dynamic languages in general are not preventing people from knowing
> the types of variables, they however remove a number of annoyances that come
> with static types. You want to bring all those back

You should note that I said "controlling" not "knowing." I don't know
what that second bit about static typing is about and why you're
accusing me of wanting to force "annoyances" on everybody else. All I
have said is I'd like to be able to control what variable types are
passed to my functions and apparently you are very much against that.

> If you want strict typing ("control the type of my variables") I'm afraid
> you're using not only wrong language but wrong paradigm. You should be using
> statically typed language. Try C# or Java or Scala or something like that.

If you want a typeless language I'm afraid you're using the wrong
language. Try ColdFusion. (is ColdFusion really typeless? I don't
remember. Sorry if I'm not as good at making snarky remarks)

More seriously, one of PHP's most popular quality is that it is
flexible. When I started using PHP, I would never initialize variables
and I would always assume that somehow someway anything passed in the
URL would become a variable. It worked great, except in some cases
where it bit me in my behind. So I bumped up the error_reporting level
and started paying attention to uninitialized variables. Fortunately,
back then no one told me "oh you want warnings on initialized
variables? You should use C++ then! Haha!" PHP was flexible enough to
allow both the absolute beginner and the slightly less beginner to
have what they want.

Today, we are faced with the possibility of giving both people who
want control over what variable types are passed to their functions
and people who want the engine to determine what values can be passed
to their functions what they want. And you're against that on...
ideological grounds?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to