Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84131 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84320 invoked from network); 1 Mar 2015 22:37:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Mar 2015 22:37:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.169 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.169 mail-qc0-f169.google.com Received: from [209.85.216.169] ([209.85.216.169:34905] helo=mail-qc0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/20-17251-B9493F45 for ; Sun, 01 Mar 2015 17:37:16 -0500 Received: by qcyl6 with SMTP id l6so22039850qcy.2 for ; Sun, 01 Mar 2015 14:37: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=Vart4oL0vy95MdFVsi7gui/5ytCEycmYjU0JHt59bkw=; b=hSpYocM2oqdvhRaP+ccgu1F81DrWhWa5W1P6SlpeCmSze4qGJyIMVE8vpF0VveHYUF NMj7CVyDviafGLXYmSjPzBtoT2DkG7fwVzEdA9SX3BXpxd1jdQQs0tY4KgC0tdrmMHao SHiD/pKUlR+V2HDhs1SHtvBJZDWDx0109p0mchGttHQmAiwnikt48IROH9PRPfYxF2ha o8jp0/RqIqbxljwAgnpGb75U7gvpRG7o1uyBHoqZhhRmNxhZIoaEDOG2oD+f4FpaSccu sIGKJc8yBBsblgvMvf5qEjUa3xyWjtl0ZeL0SEH1IwhnsKld8rPtAD0+5Ayjti8PY73d N8tA== X-Received: by 10.140.238.2 with SMTP id j2mr46808882qhc.5.1425249433170; Sun, 01 Mar 2015 14:37:13 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.198.8 with HTTP; Sun, 1 Mar 2015 14:36:33 -0800 (PST) In-Reply-To: <54F38D29.9080007@gmail.com> References: <54F38D29.9080007@gmail.com> Date: Mon, 2 Mar 2015 07:36:33 +0900 X-Google-Sender-Auth: Ym9z6EG-wQe2k8vWh8lZT8-e7S0 Message-ID: To: Stanislav Malyshev Cc: Dan Ackroyd , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1135a5142e3a6b051041bebf Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Constructor behaviour of internal classes From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1135a5142e3a6b051041bebf Content-Type: text/plain; charset=UTF-8 Hi Stas, On Mon, Mar 2, 2015 at 7:05 AM, Stanislav Malyshev wrote: > > This email is to announce the formal opening of discussion for an RFC > > to clean up the behaviour of the constructors shown by several > > internal classes. > > > > https://wiki.php.net/rfc/internal_constructor_behaviour > > I'm not sure why this RFC assumes the exception is much better than > returning null. Exceptions are harder to handle (requires separate > syntax construct) and they are more expensive at runtime (must create an > object, collect the backtrace, etc.). Also, not catching the exception > immediately usually will lead to a complete application failure (usually > with an obscure error message like "internal operation failed", since > displaying raw exceptions to the user can be unsafe) instead of > finer-grained handling. > It is a long standing tradition in PHP that operations that can be > expected to fail - like fopen(), date_create(), etc. - do not produce > fatal errors but instead return error values which can be checked for > and handled. It is true that some SPL classes departed from that, but > this IMO was not an improvement but rather an annoyance that each time > you use an SPL thing you have to write it in a try/catch block. That > leads to much more boilerplate code than necessary. > > Now I understand that PHP model of doing things may be unusual for some > people that come from other language background where everything throws > exceptions for any slightest reason and there's no other means of error > checking. But I think we can do better rather than that and have more > flexible error handling - even if it would require people to be > introduced to a concept they were not familiar with before coming to > PHP, such as not using exceptions for everything. I can understand your argument. It works. This proposal is about code modularization. Software engineering is a history of better modularization. - Structured programming - Object Oriented programming - AOP - DbC Exception is one of them. While error handling without exception works, it decreases modularization. Therefore, it decreases maintainability and increases chance of bugs. Besides modularization, consistency is important for programming language also. These are the topic/objective for this RFC. IMHO. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1135a5142e3a6b051041bebf--