Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48411 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46288 invoked from network); 23 May 2010 13:10:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 May 2010 13:10:29 -0000 Authentication-Results: pb1.pair.com header.from=davey@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=davey@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 207.97.245.143 as permitted sender) X-PHP-List-Original-Sender: davey@php.net X-Host-Fingerprint: 207.97.245.143 smtp143.iad.emailsrvr.com Linux 2.4/2.6 Received: from [207.97.245.143] ([207.97.245.143:58553] helo=smtp143.iad.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/CC-54147-44929FB4 for ; Sun, 23 May 2010 09:10:29 -0400 Received: from relay24.relay.iad.mlsrvr.com (localhost [127.0.0.1]) by relay24.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id 6AACB1B4080; Sun, 23 May 2010 09:10:26 -0400 (EDT) Received: by relay24.relay.iad.mlsrvr.com (Authenticated sender: davey-AT-pixelated-dreams.com) with ESMTPSA id EE0C31B4069; Sun, 23 May 2010 09:10:24 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: text/plain; charset=us-ascii In-Reply-To: <0F9B2086-BEF9-4621-8518-73DA64B1008D@pooteeweet.org> Date: Sun, 23 May 2010 09:10:20 -0400 Cc: Sebastian Bergmann , internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <25952FF9-2E3E-4E4D-9894-245A2624E5AD@php.net> References: <7.0.1.0.2.20100522175819.0a601c68@zend.com> <93EFAEF4-26F3-44A1-85ED-5E71E665B966@pooteeweet.org> <698DE66518E7CA45812BD18E807866CE0427ED12@us-ex1.zend.net> <0F9B2086-BEF9-4621-8518-73DA64B1008D@pooteeweet.org> To: Lukas Kahwe Smith X-Mailer: Apple Mail (2.1078) Subject: Re: [PHP-DEV] Type hinting From: davey@php.net (Davey Shafik) On May 23, 2010, at 8:51 AM, Lukas Kahwe Smith wrote: >=20 > On 23.05.2010, at 14:44, Sebastian Bergmann wrote: >=20 >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >>=20 >> On 05/23/2010 01:08 AM, Ilia Alshanetsky wrote: >>> any mistmatch results in an error >>=20 >> An error that is recoverable. So not only is the "strict typing" >> optional, but "type mismatches" can be caught and handled. >=20 > again .. are you saying that a recoverable error is more than a way to = display a nice error message instead of a white screen? >=20 > anyway, the fundamental question at hand is where the "burden" of = correct typing should be placed, on the API consumer or on the API = provider. this also ties in with the question if API consumers are = likely to have "properly" typed (aka typed in the way the _various_ API = he consumes expect) by default or not. i think this is the key question = to answer when deciding to go with enabling type hinting or full out = strict typing. We also already have a precedent for type-caring functions in the = ctype_* functions: $ php -r 'var_dump(ctype_digit(123), ctype_digit((string) 123));' bool(false) bool(true) ctype_digit() simply returns a false when a non-string is passed in. Everybody knows you just cast the param to string (as in my second = call); and with no help from a notice or error of any kind. I think if we type-juggle the inputs, and threw a _notice_, people who = *care* about the precision of their data, will be informed by the notice and can change = it. Everyone else will just get expected behavior for the function with their data. It might be useful to have some way to figure out that a variable was = cast however, is that something we can store in the ZVAL and pull out with a function? = (only the type casting that occurs due to this mechanism, not any other). I don't think = this is useful enough for any kind of performance hit mind you ;) - Davey