Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84218 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63829 invoked from network); 3 Mar 2015 07:27:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Mar 2015 07:27:35 -0000 Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wg0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:41070] helo=mail-wg0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/E1-48125-56265F45 for ; Tue, 03 Mar 2015 02:27:34 -0500 Received: by wghl18 with SMTP id l18so38110541wgh.8 for ; Mon, 02 Mar 2015 23:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5P0pkuK+Va4gcMVrhN8RvFkxfQ/WSO6oLFPFygAAWyk=; b=LK6hIAzyOD6nKwV2vv6tCUlEOIsHLXidsnScdBa2H7xAWlBBx4FLo3+PgUBwsd+HIa Pl7hzJ1X31Zi2kA4UaPedfIH4lZMej22G+COa6L5WovSwX1RFiTTd54TJtH/sV2cvi8n YB78nA7PGPcavlfoGLchtuGjM/78UxjXVXcFEC2ivuLCadKAeHTHbpQUTU0DBGiva0AE QG2/UXamnO0vl7wiMhz4EH+mjbzJXhHT122Y29JGSXdY+U6vzIUSqSsDMZULYtwfSEda qKqgMehPOJONmAOJkERj5OCE3ZaolmSr25dzvhTRMsaqsoy1OCdxwgzKzhtyKk1VrRAu Az2Q== X-Received: by 10.181.27.199 with SMTP id ji7mr2988wid.76.1425367650937; Mon, 02 Mar 2015 23:27:30 -0800 (PST) Received: from lepisma.bemi (89-104-28-113.customer.bnet.at. [89.104.28.113]) by mx.google.com with ESMTPSA id dj4sm24819wjc.13.2015.03.02.23.27.29 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Mar 2015 23:27:29 -0800 (PST) Sender: Michael Wallner Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: <54F49882.9090901@gmail.com> Date: Tue, 3 Mar 2015 08:27:29 +0100 Cc: Dan Ackroyd , "internals@lists.php.net" Content-Transfer-Encoding: quoted-printable Message-ID: References: <54F38D29.9080007@gmail.com> <54F417E1.8010703@php.net> <54F49882.9090901@gmail.com> To: Stanislav Malyshev X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Constructor behaviour of internal classes From: mike@php.net (Michael Wallner) >> Consistency with userland is beneficial, because the majority of PHP >> developers probably do not expect `new` to yield anything than a >> concrete instance or an exception. >=20 > Of course, consistency with userland is beneficial. However, in = userland > we do not have many things that we have in internals - like operator > overloading, function aliasing, etc. - because some of the = functionality > we consider risky and as such better to be left to = internals/extensions. > This is one more example. >=20 None of them cause a fatal error, because it behaves contrary to = established=20 standards. >> Quoting php.net/manual: >>=20 >> To create an instance of a class, the new keyword must be used. = An >> object will *always* be created *unless* the object has a constructor >> defined that *throws an exception on error*. >=20 > Manual can be fixed. Everything can be =E2=80=9Cfixed=E2=80=9D, but what=E2=80=99s the right = thing to fix? Documentation=20 valid for a decade that covers 98% of use cases, which will cause = everyone=20 to revisit any instance of `new` with internal constructors or rather = fix those=20 internal classes misbehaving.=20 >=20 >> Do you know of any other case where a `new` operator in an object >> oriented context can return NULL, except C++ where you have to >> explicitly ask for that behavior? >=20 > I can't say I am familiar with every OO language's implementation > details, so I don't know. But I don't see why, if we think it's = useful, > we can not do it - especially given our factory methods/functions > already do it. I think it's useful. That=E2=80=99s okay, but do you think the majority of PHP developers = finds that=20 undocumented and unexpected behaviour useful? To me this is as useful as an internal class crashing because it = doesn=E2=80=99t=20 check if it was instantiated correctly. Regards, Mike