Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91847 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9894 invoked from network); 22 Mar 2016 14:56:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Mar 2016 14:56:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.25 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.25 out1-smtp.messagingengine.com Received: from [66.111.4.25] ([66.111.4.25:59573] helo=out1-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/08-46740-43D51F65 for ; Tue, 22 Mar 2016 09:56:53 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5686B21583 for ; Tue, 22 Mar 2016 10:56:50 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 22 Mar 2016 10:56:50 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Tg1Uopypcaodoh2 IP0hVPrPsAKY=; b=fFFqsFonxSkp8zS6Vtusf+450nrp8hq7cb8+dRJPaJHC2ex qAJNfvewvPHUgJ7/cF6Gu/QNbBbLwjquM1rztHHXvud+X0F9HFxILCpQLNnmoWYs I0gLvGl432vqLr4oz0JQHvmhNhXCboNVRrXhnTHqy5L0widy5jI+5WVGAzEk= X-Sasl-enc: nYKQaVbhwH5DOODUKOtbFfQ/GIZIomWLybU3673vlbOG 1458658610 Received: from Crells-MacBook-Pro.local (unknown [63.250.249.138]) by mail.messagingengine.com (Postfix) with ESMTPA id 22261C00016 for ; Tue, 22 Mar 2016 10:56:50 -0400 (EDT) To: internals@lists.php.net References: <2070425.mznTmPgxij@mcmic-probook> Message-ID: <56F15D31.5070405@garfieldtech.com> Date: Tue, 22 Mar 2016 09:56:49 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <2070425.mznTmPgxij@mcmic-probook> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods From: larry@garfieldtech.com (Larry Garfield) On 3/21/16 10:23 PM, Côme Chilliet wrote: > Le lundi 21 mars 2016, 17:04:30 Facundo Martinez Correa a écrit : >> But then I realized the problem. There >> are many times where we need uncertainty. Code is a reflection of reality, >> and as such, it must reflect uncertainty. NULL is a good enough way to >> express nonexistence, albeit a bad one. We have been using it in code for >> years, but it is also used to say many things. Things that cause >> uncertainty in the code. I receive a null, does it mean it doesn't exists? >> That it will exist? Should I allow it? Is it a good value? I for sure don't >> know. And in my experience, I have used it for many of those cases. And in >> many situations that I'm not proud of, all of them at the same time. > If your function is supposed to return a User and can’t, maybe it should throw an Exception. > Just wanted to point out it can be a good alternative to returning NULL for error handling. > > Côme In the PHP 7 and typing presentations I've been giving[1], I've advocated either: 1) Throw an exception if the rest of the code is going to break anyway. 2) Define an empty object with matching interface if you want an equivalent of 0/empty string. While a monad sounds cool, it doesn't seem like the necessary language infrastructure is there for it at the moment. [1] My most recent talk that has a section on returns: https://youtu.be/rWDY4-LJils?t=2m38s (that's where the return type segment starts) Slides: https://www.palantir.net/presentations/midcamp2016-php7/ -- --Larry Garfield