Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49356 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60537 invoked from network); 11 Aug 2010 16:56:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2010 16:56:38 -0000 Authentication-Results: pb1.pair.com header.from=phpwnd@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=phpwnd@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: phpwnd@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pw0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:51481] helo=mail-pw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/FA-01618-546D26C4 for ; Wed, 11 Aug 2010 12:56:38 -0400 Received: by pwj8 with SMTP id 8so144848pwj.29 for ; Wed, 11 Aug 2010 09:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=kpheCtYrdQK7Gx1yO5GJzD0/Iz5RjHdnbKQU2cjbgXc=; b=WdCxnKKAoTEUKHQ36vJ/D2Zkssa7wZitCHG/v23C++1DX/LPiSSw2uMtS6sxDxM91Q jJkXEGqpYyfisVmqtRVoxJu/Du57a7wPSGnW+6qdVxmEr8nIdh78cJ5PcD9rvcpIxDUS WyUw0Hp0fr+1qzyb/YJcQsB2ne35SSWn4kOAw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=iDMzV9lY4M6GMP5Szvw0CnHNuGX7R/EIDEScdKe3juCH2/Z9VSv/CEvSUvvf219zpg EarF3Eg8t9cczyujk2J9dTWNRRQRAru34CT+bua+Yl+h52SpHTkeUbUKH/UUn/qgX1Sv eorDKyPUE2aTgYgMCq1xxpKCNPTkqmy7pS/Eg= MIME-Version: 1.0 Received: by 10.114.15.18 with SMTP id 18mr22175606wao.182.1281545795087; Wed, 11 Aug 2010 09:56:35 -0700 (PDT) Received: by 10.114.154.9 with HTTP; Wed, 11 Aug 2010 09:56:34 -0700 (PDT) In-Reply-To: <4C6241D1.6030909@sugarcrm.com> References: <1281478269.6608.292.camel@guybrush> <4C61E5CA.5070604@sugarcrm.com> <4C61F3EF.5030409@sugarcrm.com> <4C6241D1.6030909@sugarcrm.com> Date: Wed, 11 Aug 2010 18:56:34 +0200 Message-ID: To: Stas Malyshev Cc: Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Strict typing From: phpwnd@gmail.com (Josh Davis) On 11 August 2010 08:23, Stas Malyshev 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?