Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84268 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4200 invoked from network); 3 Mar 2015 23:56:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Mar 2015 23:56:17 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.53 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.192.53 mail-qg0-f53.google.com Received: from [209.85.192.53] ([209.85.192.53:54655] helo=mail-qg0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/F1-22264-F1A46F45 for ; Tue, 03 Mar 2015 18:56:16 -0500 Received: by mail-qg0-f53.google.com with SMTP id j5so12556172qga.12 for ; Tue, 03 Mar 2015 15:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=t7Z2ZIc83RJ0OVQ01z11aCq6LZRwhh5eM2ZsxVYI2Rw=; b=Wvu6nhgHdgBgayIxiF24CDwQnLZqidPakqVKxzKp0HOBZkNanOe6kqX39x3bF+k4cF vOV2EERdMilbwXwNnCyPDfb4TG0QO5zPgCNirDRwsNZZ+WIp1tBTW9GY36+Gt63vi4wS b5tbCOWC/j3bEagGvT0J3IgMjE53s8qA9O0L4IWgLfqgam3RuBS71kHR667EvDTMxsFr B6duEK8RoEzYZiGgfQesuH6FxetxK5wzTaGGn7+dE2y+/WjsOpj5FT32T3GEdjuUHZ5p dzIlY6XqBpN4n7GFCeFu95wJtHRsoRMmktKjKgUj/Lt5J3O3x+toFTMkaunv0EPohXzD 0kew== X-Received: by 10.55.23.25 with SMTP id i25mr2669739qkh.12.1425426973288; Tue, 03 Mar 2015 15:56:13 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.198.8 with HTTP; Tue, 3 Mar 2015 15:55:33 -0800 (PST) In-Reply-To: References: <54F38D29.9080007@gmail.com> <54F417E1.8010703@php.net> <54F49882.9090901@gmail.com> Date: Wed, 4 Mar 2015 08:55:33 +0900 X-Google-Sender-Auth: wxjyMmbeSkmGo1pfEqIspxQFnEw Message-ID: To: Michael Wallner Cc: Stanislav Malyshev , Dan Ackroyd , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a114596a8656d7205106b1418 Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Constructor behaviour of internal classes From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a114596a8656d7205106b1418 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi all, On Tue, Mar 3, 2015 at 4:27 PM, Michael Wallner wrote: > > > >> 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? > > > > 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 find= s that > undocumented and unexpected behaviour useful? > To me this is as useful as an internal class crashing because it doesn=E2= =80=99t > check if it was instantiated correctly. Let's be consistent. If error happened during object instantiation, raise exceptions. Returning NULL for this case would be OK. We may be better to be consistent because exceptions can be ignored. There are 2 possibilities, return NULL or FALSE Always return NULL or FALSE for errors? Many procedural functions return FALSE for error. Most notable exceptions are argument count errors that return NULL. It may be better cleanup these inconsistent behaviors also. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a114596a8656d7205106b1418--