Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-09 Thread Григорий Senior PHP / Разработчик Web
> I've worked on PHP (and non-PHP) applications with (tens of) millions of lines of code Grats, you're a hero. Now, you're a hero. You can solve the application in your paper notebook. That does not explain why computers should know some correctness and not help you, because you're a hero. I now

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-09 Thread Robert Landers
On Thu, Feb 8, 2024 at 8:57 PM Григорий Senior PHP / Разработчик Web <6562...@gmail.com> wrote: > > 1. Do some benchmark with > > ``` > > function a($a, $b) > { > return $a + $b; > } > > function aa($a, $b) > { > throw new \Exception(); > > return $a + $b; > } > > $bag = []; > > $mt

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Григорий Senior PHP / Разработчик Web
1. Do some benchmark with ```

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Григорий Senior PHP / Разработчик Web
>From that point of view you're absolutely correct. I want to use json_last_error() with global state, but with the ability to manually change the state size to prevent memory overflow. So I suggested it because the count of bad code will grow in arithmetic progression because of the times on the

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Larry Garfield
On Thu, Feb 8, 2024, at 11:15 AM, Григорий Senior PHP / Разработчик Web wrote: > Just because PHPStan is a ready solution for design errors that you can > predict. > My case is about errors that you detect later, after the design is > finished, PHPStan shows you that "all done!". > > Because it's n

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Григорий Senior PHP / Разработчик Web
Just because PHPStan is a ready solution for design errors that you can predict. My case is about errors that you detect later, after the design is finished, PHPStan shows you that "all done!". Because it's not \LogicExceptions (types, mappings), it's all \RuntimeExceptions... You have to implemen

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Arvids Godjuks
On Thu, Feb 8, 2024, 12:12 Alexander Pravdin wrote: > On Thu, Feb 8, 2024 at 6:25 PM Григорий Senior PHP / Разработчик Web > <6562...@gmail.com> wrote: > > > > PHPStan is out the case. > > > > May I know why is it out? > > I'm actively using it in my projects and it helps me a lot to not > relax

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Alexander Pravdin
On Thu, Feb 8, 2024 at 6:25 PM Григорий Senior PHP / Разработчик Web <6562...@gmail.com> wrote: > > PHPStan is out the case. > May I know why is it out? I'm actively using it in my projects and it helps me a lot to not relax and write safe code. It also helps a lot in cleaning up legacy code. Som

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Григорий Senior PHP / Разработчик Web
Ok, I understand your position. Want explanations about personal behavior - please write by telegram. PHPStan is out the case. SOLID is not a marker of good architecture, it's a marker of idealistic understanding, for me. I already long ago passed that time where I can just say "this code is bad

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-08 Thread Alexander Pravdin
On Thu, Feb 8, 2024 at 4:02 PM Григорий Senior PHP / Разработчик Web <6562...@gmail.com> wrote: > > JIT I've had this solved, not only the application, but a way to. > > Am sharing my experience without labels "bad", "cood", "truth" or "correct", > like you did. > > Your arguments are based on you

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Григорий Senior PHP / Разработчик Web
JIT I've had this solved, not only the application, but a way to. Am sharing my experience without labels "bad", "cood", "truth" or "correct", like you did. Your arguments are based on your principles and I don't see in your words any point to discuss, so - use pm or share here secret of error-fr

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Alexander Pravdin
On Thu, Feb 8, 2024 at 2:29 AM Григорий Senior PHP / Разработчик Web <6562...@gmail.com> wrote: > I still don't understand why the problem is signature and moving a simple > throw statement to return type, and then rewriting the catch statement to > oneline-r. Sorry for answering not directly to

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Григорий Senior PHP / Разработчик Web
I still don't understand why the problem is signature and moving a simple throw statement to return type, and then rewriting the catch statement to oneline-r. I am completely satisfied with the php way of working with method signatures except non-critical cases: - still no `undefined` type, so som

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Larry Garfield
On Wed, Feb 7, 2024, at 12:55 AM, Alex Wells wrote: > On Tue, Feb 6, 2024 at 7:14 PM Larry Garfield > wrote: > >> These two samples *are logically identical*, and even have mostly the same >> performance characteristics, and both expose useful data to static >> analyzers. They're just spelled dif

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Григорий Senior PHP / Разработчик Web
As I mentioned above - javascript pipelines (named `Promise` and `Thenable`) are great examples when exceptions are a bad choice. Btw, not "bad", but "choice to stop one step of the chain only". If any step of chain/foreach throws an exception - it will break all code. Should break one step. That'

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Григорий Senior PHP / Разработчик Web
Analyzing the problem on a single level operation is incorrect. New code and simple operations are fully covered with exception/try/catch flow. The main point i tried to attract your attention is that if you working in batches/queues/pipelines you still need errors collection, and if you made erro

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Larry Garfield
On Wed, Feb 7, 2024, at 10:21 AM, Robert Landers wrote: >> I think there's a subtle but important difference here between what you're >> describing as the problem and what you implied the solution was (which I >> then ran with). >> >> What you're talking about is trying to change the error hand

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Robert Landers
On Wed, Feb 7, 2024 at 11:27 AM Григорий Senior PHP / Разработчик Web <6562...@gmail.com> wrote: > > Yes, that was the second build of the error bag I presented in the github > ticket. > First one was a Trait that added an error bag as property in class and > returned an array with two results. >

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Григорий Senior PHP / Разработчик Web
Yes, that was the second build of the error bag I presented in the github ticket. First one was a Trait that added an error bag as property in class and returned an array with two results. The trouble was you have to refactor all places you used your function doesn't matter, want you or not. And

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-07 Thread Robert Landers
On Tue, Feb 6, 2024 at 9:22 PM Larry Garfield wrote: > > On Tue, Feb 6, 2024, at 7:56 PM, Григорий Senior PHP / Разработчик Web wrote: > > Thanks Larry, I will read both articles next weekend. > > > > Am not even talking about changing `throw` to `raise`. > > > > Am talking only about: > > - produ

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
Thanks for suggestion about assert() use cases, i know it exists before, but never used. Usually if something shouldn't happen i throw exception there, or at least type control. Its like manual mark for the future - you doing something wrong, fix it. Error collection case its about "you're right,

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Alex Wells
On Tue, Feb 6, 2024 at 7:14 PM Larry Garfield wrote: > These two samples *are logically identical*, and even have mostly the same > performance characteristics, and both expose useful data to static > analyzers. They're just spelled differently. The advantage of the second > is that it could be

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Weedpacket
On 2024-02-07 09:08, Larry Garfield wrote: "The right tool for the job" is indeed the strongest argument for lightweight exceptions. It's a tool we lack right now. I'm thinking not of "DB went away" type issues (Exceptions are already fine there), but "requested product not found." Right no

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Larry Garfield
On Tue, Feb 6, 2024, at 7:56 PM, Григорий Senior PHP / Разработчик Web wrote: > Thanks Larry, I will read both articles next weekend. > > Am not even talking about changing `throw` to `raise`. > > Am talking only about: > - production ready code > - that should be able to refactor with error collec

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Arvids Godjuks
On Tue, 6 Feb 2024 at 22:09, Larry Garfield wrote: > On Tue, Feb 6, 2024, at 7:18 PM, Arvids Godjuks wrote: > > >> To be clear: I really like this concept and have discussed it with > others > >> before, using almost exactly this syntax. I have not proposed it > because > >> my read of Internals

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Larry Garfield
On Tue, Feb 6, 2024, at 7:18 PM, Arvids Godjuks wrote: >> To be clear: I really like this concept and have discussed it with others >> before, using almost exactly this syntax. I have not proposed it because >> my read of Internals lately is that there's no stomach for more >> type-centric behavi

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
Thanks Larry, I will read both articles next weekend. Am not even talking about changing `throw` to `raise`. Am talking only about: - production ready code - that should be able to refactor with error collectors (that was not implemented years ago) - without touching return types - without touchi

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Jordan LeDoux
On Tue, Feb 6, 2024 at 11:19 AM Arvids Godjuks wrote: > On Tue, 6 Feb 2024 at 19:14, Larry Garfield > wrote: > > Thank you Larry for this interesting summary - didn't remember there was > quite a bit a discussion around the topic prior. > > I lean on the "we have exceptions, just leave it be" si

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Arvids Godjuks
On Tue, 6 Feb 2024 at 19:14, Larry Garfield wrote: > On Tue, Feb 6, 2024, at 4:13 PM, Григорий Senior PHP / Разработчик Web > wrote: > > Btw, i agree about Javascript, but on a low level it produces the most > > clean code, because there's no types and rules. All types moved to > > TypeScript's c

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Larry Garfield
On Tue, Feb 6, 2024, at 4:13 PM, Григорий Senior PHP / Разработчик Web wrote: > Btw, i agree about Javascript, but on a low level it produces the most > clean code, because there's no types and rules. All types moved to > TypeScript's client side compiler. > > JS 15 years ago ACCIDENTALLY created a

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
Btw, i agree about Javascript, but on a low level it produces the most clean code, because there's no types and rules. All types moved to TypeScript's client side compiler. JS 15 years ago ACCIDENTALLY created a pipeline. Named it "Promise". We spent years after to understand that while (true) and

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
My function seems like this: ``` _error_bag_error(error) { if (stack.errorBag) { stack.errorBag.add(error); } } ``` It does nothing if i didn't initialize the error bag manually. I should call _error_bag() inside the current function to create one in the stack, or _error_bag_push() (and

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Arvids Godjuks
JavaScript is JavaScript - it's not a good role model to look at. If anything, JavaScript is a collection of things of how not to design a language :) What you are looking for is Golang. The level of changes you are proposing require it to go thriugh an RFC process, have 2/3rds of voters to agree

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
Javascript is closer to. It allows you to throw anything, but it is still the throw statement, keeping in the mind the async nature of js - memory and processor stuff is shared by the time. JS seniors usually hate those guys who throw anything except language Error class because they skipped the

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Robert Landers
On Tue, Feb 6, 2024 at 4:26 PM Григорий Senior PHP / Разработчик Web <6562...@gmail.com> wrote: > > Short answer is yes. Glad to see that personally adapted answer. > > That's why in the relevant github issue i show how to collect ONLY if you > need. > If you initialize the error bag - it collects,

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Alex Wells
On Tue, Feb 6, 2024 at 5:26 PM Григорий Senior PHP / Разработчик Web < 6562...@gmail.com> wrote: > Short answer is yes. Glad to see that personally adapted answer. > What are those languages specifically?

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Alex Wells
On Tue, Feb 6, 2024 at 3:58 PM Григорий Senior PHP / Разработчик Web < 6562...@gmail.com> wrote: > - add non-breakable interface and language construct `raise` to "throw" > error without collecting trace > - that error could be any scalar or object, or you can implement new > interface for them, k

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
Short answer is yes. Glad to see that personally adapted answer. That's why in the relevant github issue i show how to collect ONLY if you need. If you initialize the error bag - it collects, if not - it skips. T So the `try/catch` statement outside means you initialized, also a special decorator

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Alexander Pravdin
On Wed, Feb 7, 2024 at 12:00 AM Григорий Senior PHP / Разработчик Web <6562...@gmail.com> wrote: > > Sending you private emails made because "answer" button in Gmail selects > only you to receive. > Sending you private emails that don't even read signs to me you don't need > my answers and have no

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
Sending you private emails made because "answer" button in Gmail selects only you to receive. Sending you private emails that don't even read signs to me you don't need my answers and have no benefits from reading. But you deny, dont even want to understand. And notify all subscribers about what yo

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Arvids Godjuks
On Tue, 6 Feb 2024 at 16:39, Arvids Godjuks wrote: > > > On Tue, 6 Feb 2024 at 15:58, Григорий Senior PHP / Разработчик Web < > 6562...@gmail.com> wrote: > >> Hello, please discuss about error collecting implementation in next PHP >> releases >> >> Exceptions have common differences that restrict

Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Arvids Godjuks
On Tue, 6 Feb 2024 at 15:58, Григорий Senior PHP / Разработчик Web < 6562...@gmail.com> wrote: > Hello, please discuss about error collecting implementation in next PHP > releases > > Exceptions have common differences that restrict using them to collect > errors > 1. Timeloss (trace collection) o

[PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301

2024-02-06 Thread Григорий Senior PHP / Разработчик Web
Hello, please discuss about error collecting implementation in next PHP releases Exceptions have common differences that restrict using them to collect errors 1. Timeloss (trace collection) on call new() on any class that implements \Throwable 2. To collect errors and return it to the upper level