Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83074 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43505 invoked from network); 18 Feb 2015 14:54:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 14:54:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:44212] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/66-18888-F87A4E45 for ; Wed, 18 Feb 2015 09:54:08 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 001564B0188; Wed, 18 Feb 2015 15:53:45 +0100 (CET) Reply-To: To: , "'PHP internals'" References: In-Reply-To: Date: Wed, 18 Feb 2015 15:54:03 +0100 Message-ID: <032701d04b8a$bc7b9490$3572bdb0$@php.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQLHLVYiZDxG2qv2xcIw64vTIniiyZsItQkQ Content-Language: fr X-Antivirus: avast! (VPS 150218-0, 18/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] Nightmares on type hints, annotations, and aop... From: francois@php.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) Hi Bishop, > De : bishop.bettini@gmail.com [mailto:bishop.bettini@gmail.com] De la = part de Bishop Bettini > > THING 1: Hints are just is_* wrappers Wrong. Only *strict* types are. > THING 2: Hints are truthy callables >=20 > function my_mixed($m) { > return (null =3D=3D=3D $m || is_string($m)); > } > function f(is_scalar $s, is_int $i, my_mixed $m) {}; Not sure I understand 'truthy callables'. Your example is a definition = of 'strict-only' union types. It's a planned feature. > THING 3: Pre- and post- blocks to define contracts, establish formal = join > points, with or without hints from above Contracts are fine but cannot completely replace type hints. I initially = followed this road but reverted to thinking that both tools have their = use. Contracts can implement performance-intensive checks but, because = of this, cannot be executed in production. Type hints are = performance-constrained but always executed. Another benefit of type = hints is that PHP does not provide a consistent set of 'weak' is_xxx() = functions yet. Checking for an integer in PHP, for instance, when you're = ready to accept 31, 31.0, or '31', is relatively complex and = unintuitive, while 'int $arg' is readable. If is_int() did a intuitive = 'PHP way' check, contracts would be an alternative, but it is too = counter-intuitive as it exists now. And BC makes changing is_xxx() = behavior impossible, of course. > I had to get these off my chest. Forgive me their implementation = ignorance. > I am yet tired and uncaffeinated. No problem. Every goodwill is welcome. > To the void I commit their bodies... Sorry, my english is too poor for that. Can you explain? Regards Fran=C3=A7ois