Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93263 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46159 invoked from network); 12 May 2016 10:21:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2016 10:21:11 -0000 Authentication-Results: pb1.pair.com header.from=me@daveyshafik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@daveyshafik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain daveyshafik.com from 209.85.217.180 cause and error) X-PHP-List-Original-Sender: me@daveyshafik.com X-Host-Fingerprint: 209.85.217.180 mail-lb0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:36719] helo=mail-lb0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/99-28272-31954375 for ; Thu, 12 May 2016 06:21:08 -0400 Received: by mail-lb0-f180.google.com with SMTP id h1so8601727lbj.3 for ; Thu, 12 May 2016 03:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daveyshafik-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=bjs+C36P7TvG7N2BN2YHjBEo2QaCwwtva5dA7yX0LbM=; b=Phc4FqSoDsZ/9jXr4eGYrTtH4QqeV0fTCXiKeeFobmqi95d4yDs4lyyCmwS/IXbPkz oKuDvXGMhJCkt4YEikL8dS8I9n3/FraWCDbQuA5VJSinpYF9QmgXlsMak0JYPOUUeYx0 KWKXnee0buDFuDUXITPFA4V7i65ts4Z3Gn6fRnZnmmmtsgIzaSfQDW/ykEnGUDRlxDZx EygtbVPwXJhr2kJh8Qk6Z3hWcUcNGkvr6Yucf4P4ivVVyUxx5zwk3WMckDGeGIp2R/z3 mUdjAMFZwTWIl/8RIaLX2KajkARksAh2JxeIRMJouh3EJLXmorNUK9PCT7ZjfFctbzV+ 19AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=bjs+C36P7TvG7N2BN2YHjBEo2QaCwwtva5dA7yX0LbM=; b=Uzak31xLGC95hzJ0223DcdcZIALZKDN1b1yKZNCJxpVDVaP11V7e4o5YE+nLFL9aNB 2vSvTdT43S2L1hc+EUALJ4AGMKdL1PYLl5QLF1jrTeONR+fBCyqD+7tQmeYYAPRPsNNj aDqm0oZiwnWCOYbDWI9q+EwrJP1V0HIgJ83yvB0ls5EiW2Ns9p16hjvbZvrPNhOxAHdP PNCBJzj8vkH+NhQ3KPVbkLDOVHa5l9mBwlB6wwZL3gaGIjaRFWur3DINeboVmLjF+0nS LWygWTwmLB8wNUPgMs/AyjYT10cfhOsNjqS4qKhQWTnccCe7EIpJ9ek1PBSFPGMfHSxY SGDw== X-Gm-Message-State: AOPr4FX/c6zeSrIDfboLgHw0uSJJJXIn1E6EO8iiXoasDspA9HQ3A5TShJkIQ7ZDMzBQ/kMfsqnLxOyXGe2moheX MIME-Version: 1.0 X-Received: by 10.112.14.97 with SMTP id o1mr2633498lbc.17.1463048464752; Thu, 12 May 2016 03:21:04 -0700 (PDT) Sender: me@daveyshafik.com Received: by 10.25.28.10 with HTTP; Thu, 12 May 2016 03:21:04 -0700 (PDT) In-Reply-To: <573308EC.70502@lsces.co.uk> References: <573232DB.8030209@lsces.co.uk> <573308EC.70502@lsces.co.uk> Date: Thu, 12 May 2016 12:21:04 +0200 X-Google-Sender-Auth: 6EEcAovw8LBOnrQQ8xL27PXTY7E Message-ID: To: Lester Caine Cc: internals Content-Type: multipart/alternative; boundary=001a11c368da0845eb0532a284d0 Subject: Re: [PHP-DEV] Re: [RFC][VOTE] Nullable Types From: davey@php.net (Davey Shafik) --001a11c368da0845eb0532a284d0 Content-Type: text/plain; charset=UTF-8 By removing the ?, the function doesn't fail because it can no longer handle a null, the _engine_ throws an error because you're no longer allowed to _pass_ a null, it doesn't even execute the function itself. If you were to either a) define it as ?Foo $foo = null in the first place, or b) change ?Foo $foo to Foo $foo = null, it would execute without error. However, the semantics of calling it has changed, in the case of ?Foo $foo, you're allowing the caller to _explicitly_ call it and pass in a null, but not to call it without specifying anything. If you add the default of null (= null), you are now allowing them to call it without anything, and _implicitly_ passing in a null. This could lead to very subtle bugs. E.g. the behavior of passing executing with a null value for the argument is something you should be consciously making a decision on, and passing in null explicitly. - Davey On Wed, May 11, 2016 at 12:26 PM, Lester Caine wrote: > On 10/05/16 21:26, Levi Morrison wrote: > > It can affect the results. > > > > function foo(?Foo $param) {} > > > > If any code out there is calling foo with null then that code will now > > break if you remove the question mark. > > Cart before Horse comes to mind ... > > If the function is going to fail if you pass in a null ... you check for > the null before calling it. OK the '?' is a flag that you need to do > that, but you really need proper documentation as to just what Foo > expects. If I've handled the null case situation, the ? is redundant? > > I'm still failing to see an overall picture of what people are trying to > achieve. Adding errors means that those errors need to be handled. If > the function gets a 'null' then there is a reason, and either the > function should not have been called ... workflow failed ... or the > function should simply handle the 'null' case. If the '?' throws an > error the workflow is broken after the event where a user code warning > would be more helpful. > > -- > Lester Caine - G8HFL > ----------------------------- > Contact - http://lsces.co.uk/wiki/?page=contact > L.S.Caine Electronic Services - http://lsces.co.uk > EnquirySolve - http://enquirysolve.com/ > Model Engineers Digital Workshop - http://medw.co.uk > Rainbow Digital Media - http://rainbowdigitalmedia.co.uk > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --001a11c368da0845eb0532a284d0--