Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106778 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12601 invoked from network); 29 Aug 2019 01:05:21 -0000 Received: from unknown (HELO mail-yb1-f172.google.com) (209.85.219.172) by pb1.pair.com with SMTP; 29 Aug 2019 01:05:21 -0000 Received: by mail-yb1-f172.google.com with SMTP id 1so538358ybj.8 for ; Wed, 28 Aug 2019 15:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Atg6050ErKiAW21LsV/s6/kqSc43jxE0R/0eG9vwEgg=; b=b0Wnlj6nakYo2CGtPbqYdyM+5vDCnub7S4wQZO+XfSUACqLRTdbfZ6T5UWcFhkvT/m JWVM4KB3a7H8t4TbETbqpPqr+I/oxsHv9qQ4yA2EvXnacvmiI1xgjouZutVZuF9PAMy9 jpPHGQDpY574ApNXqO7MeR7GWKg/LC5xD09RCIC46AWoeE1boLTSSpK48yYLqDlZRBLw FlDundvPp7qiYdyXoQznp+IALyDsl46s1x4TcqC5GEjI8rsvoMudF2fcP1KwoGnBQQzO m3+aAeYQeZXQL3qHDqdvjXwCR2BluYNlw5fYjQyrJYuh1oF1U/o9BHlBX6hE8F2x1mHN PSkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Atg6050ErKiAW21LsV/s6/kqSc43jxE0R/0eG9vwEgg=; b=Q56f8fSdwg5UePto8d9qIGZI/A6gg4EjVPtgFl3h8gUNmhENSckWaqWAmY1utExDgG FpA7QfXIMUqNF+7c+/UOE9TAyx4KLnQ1fq+0dnabRBPAM4/5Yzg55n+Y7XsQFmcG10n+ +jdgDot2nV4WvogO1/lpALonc5pDr14PC4bjcYQ9X6tuOVRBZHbz3EJAT8+RxnylT52A bKVokPyYWRPmeeKGE2zd6X0x9sxduhBuFDKLzKOnMJ1/spIFkjll3UG0dAVQKZmNSirm 3gTT0dPOdeyLi8TGMJgMIquVUKrnq42sQ6daaQuWK5BRwQCPAVo9vHRtS84LGTpSaStR D/Yw== X-Gm-Message-State: APjAAAXnBJ5qbsp7G8cMPOvX1WGBrQffxkF2hsK89YG6K59NR2o43XAm oVT5lroomsKocw5dp2XZfIy8/rMrVrr09a/KEYQ= X-Google-Smtp-Source: APXvYqw9KzSd7ZzNIf0K3pVb1XpDeXkb81fwiYfHCZpmTvLa6AVa7TQz4PxwQr1ro0xSoSL3iv12chaO2oBl1QsgU8o= X-Received: by 2002:a25:e08d:: with SMTP id x135mr4834006ybg.239.1567031856289; Wed, 28 Aug 2019 15:37:36 -0700 (PDT) MIME-Version: 1.0 References: <6ed74ae0-5feb-39de-a39a-f9a8f80401b2@gmail.com> <342BB5DE-80D0-405E-8C71-D959F38D17E8@gmail.com> In-Reply-To: Date: Wed, 28 Aug 2019 18:37:24 -0400 Message-ID: To: Stanislav Malyshev Cc: Zeev Suraski , PHP internals Content-Type: multipart/alternative; boundary="000000000000255b030591350924" Subject: Re: [PHP-DEV] [RFC] Reclassifying engine warnings From: matthewmatthew@gmail.com (Matthew Brown) --000000000000255b030591350924 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This is where I think PHP may have broken us a little. I just asked a few non-PHP developers here what they expect "(function () { $a++; })()" to do, and they agreed it would be some sort of error. Got the same answer for "(function () { $a->bar =3D 5; })() ". Indeed, anyone who's used another C-like language (JS, TS, Java, C# etc) is used to these things being errors, so it can be disorientating to see them treated as anything else by PHP (it was disorientating for me, at least). On Wed, 28 Aug 2019 at 18:06, Stanislav Malyshev wrote: > Hi! > > > If we want PHP to be as easy as possible then $nullref->bar(), > > $foo->someUndefined(), new UndefinedClass etc shouldn=E2=80=99t be exce= ptions > > either - they can just be notices. > > I don't see how it follows. Calling unknown method does not have natural > default - if I tell you "would you please do abracadabra" you can't just > do something random and consider it done - you should tell me "what do > you mean by that? Please explain what you want me to do". > However, if I tell you "here's an apple, add it to your pocket", then > there's a natural way of knowing how many apples is in your pocket for > every state of your pocket before - if your pocket was empty, it now has > one apple, if it had apples before, now it has one more. I don't need to > explain you what to do when your pocket is empty and when it's not > separately - you can guess intuitively what should happen in each case > and you'd be 100% right always. > > That's the natural difference between $foo++ and foo() - in the former > case, you know what should happen in any case (including when $foo is > initialized to a non-numeric value - *then* you error out), in the > latter, if foo() is not defined, there's no natural way to go but to > error out. There's a crucial difference here because variables are > containers, not actors. Dealing with an empty container has natural > semantics (in some cases at least), dealing with non-existing actor does > not. > -- > Stas Malyshev > smalyshev@gmail.com > --000000000000255b030591350924--