Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80698 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84161 invoked from network); 17 Jan 2015 15:43:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jan 2015 15:43:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap11-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:54629] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/71-09166-0138AB45 for ; Sat, 17 Jan 2015 10:43:15 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 3CF2F8800DB; Sat, 17 Jan 2015 10:43:10 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gmaUJ3TVIzUR; Sat, 17 Jan 2015 10:43:10 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id BAFC18800D5; Sat, 17 Jan 2015 10:43:08 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <003201d0326b$6fd27f60$4f777e20$@tekwire.net> Date: Sat, 17 Jan 2015 15:43:05 +0000 Cc: Dan Ackroyd , internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <23490588-0131-4B0F-A7AA-C9C8C766626C@ajf.me> References: <003201d0326b$6fd27f60$4f777e20$@tekwire.net> To: francois@tekwire.net X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] Class constructor behaviour From: ajf@ajf.me (Andrea Faulds) Hi Fran=C3=A7ois, > On 17 Jan 2015, at 15:37, Fran=C3=A7ois Laupretre = wrote: >=20 > I would prefer deciding that returning null is the standard way for a = constructor to inform the PHP core that the object creation failed (for = any reason). This would be trapped by the core and cause a catchable = fatal error. >=20 > This is more compatible with the 'exception-less' behavior of the core = in general. The constructor is still free to throw an exception but this = wouldn't be encouraged nor the standard way to inform the core that an = error occurred. I don=E2=80=99t really agree here. For some reason we have this = tradition of not using exceptions for =E2=80=9Cprocedural=E2=80=9D = stuff. That sort of makes sense for functions, but classes are =E2=80=9COO= P=E2=80=9D and therefore I don=E2=80=99t see a good reason why they = shouldn=E2=80=99t throw exceptions. Exceptions and OOP (and namespaces, = even) should not be the domain of userland exclusively, they are also = the domain of internals/core. If you really hate exceptions, I=E2=80=99d = say you should just use one of those ridiculous =E2=80=9Cprocedural=E2=80=9D= alternative functions (that are just methods in disguise) that we went = to the bother of adding. By the way, it irks me (and many others) that PDO doesn=E2=80=99t throw = exceptions by default. It really ought to, it=E2=80=99s an OOP API, = I=E2=80=99d love to see that changed in PHP 7. Thanks. -- Andrea Faulds http://ajf.me/