Re: [PHP-DEV] Iteration III: Packages (was Re: [PHP-DEV] [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript)

2024-07-01 Thread Alexander Pravdin
On Tue, Jul 2, 2024 at 1:20 AM Rowan Tommins [IMSoP] wrote: > On 1 July 2024 15:37:49 CEST, Alexander Pravdin > wrote: > >I personally support the movement from the current "plain-text > >template-first" language to a "coding-first" language, where f

Re: [PHP-DEV] Iteration III: Packages (was Re: [PHP-DEV] [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript)

2024-07-01 Thread Alexander Pravdin
Sorry for getting into this hot topic. Just wanted to add my two cents. > Really, the only targets we should be looking at, IMO, are: > > 1. Package-level visibility. > 2. Giving the compiler/optimizer/JIT a larger "scope" of code to > compile/optimize at once, so it can do smarter things. > > I

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2024-04-27 Thread Alexander Pravdin
loat parameters are converted to decimals implicitly according to the conversion rules mentioned above. I hope this version of the design is closer to being accepted by the community. Please share your thoughts. -- Best, Alexander -- Best regards, Alex Pravdin Interico On Wed, Apr 10, 2024 at 1

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2024-04-09 Thread Alexander Pravdin
On Tue, Apr 9, 2024 at 7:52 PM Derick Rethans wrote: > Adding a new native type to PHP will create a large change. Not only is > it "just" adding a new native type, it also means all of the conversions > between types need to be added. This is not a small task. I understand this :) > If you wa

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2024-04-08 Thread Alexander Pravdin
On Tue, Mar 19, 2024 at 5:35 AM Rowan Tommins [IMSoP] wrote: > I think a reasonable number of people do share the sentiment that having two > separate modes was a mistake; and neither mode is actually perfect. It's not > about "making it on by default", it's about coming up with a unified > be

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2024-04-08 Thread Alexander Pravdin
On Mon, Apr 8, 2024 at 5:06 PM Rowan Tommins [IMSoP] wrote: > If we ever do want to make decimals a native type, we would need some way to > initialise a decimal value, since 1.2 will initialise a float. My original suggestion was: - Add "default decimal" mode with the "declare" statement in t

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-01 Thread Alexander Pravdin
On Tue, Apr 2, 2024 at 9:18 AM Ilija Tovilo wrote: > > Hi everyone! > > I'd like to introduce an idea I've played around with for a couple of > weeks: Data classes, sometimes called structs in other languages (e.g. > Swift and C#). > > ```php > data class Vector { > private $values; > > pu

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2024-03-17 Thread Alexander Pravdin
Sorry for the so late reply, but I would like to continue the discussion on this topic. On Tue, Dec 12, 2023 at 10:04 PM G. P. B. wrote: >> I didn't know that the strict types directive was a mistake. My intention is >> to be able to write clean all-decimal units of code and not break the >>

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 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 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-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] `PDO::FETCH_CONSTRUCTOR` fetch mode proposal

2024-01-18 Thread Alexander Pravdin
I would also suggest supporting readonly classes and creating special attributes to help map data fields to constructor arguments. Something like this: readonly class User { public function __construct( #[PDOField('user_id')] public string $userId, #[PDOField('user_nam

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Alexander Pravdin
> > So you want to introduce a SAPI that doesn't work with any of the existing > HTTP solutions people use that only supports HTTP requests? Or am I > misunderstanding something? > > This sounds a bit like you want to merge in a tool that is designed for > your personal product directly into core.

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2023-12-13 Thread Alexander Pravdin
On Wed, Dec 13, 2023 at 6:11 PM Robert Landers wrote: I just ran `apt install php8.3-decimal` and tried this: > > $a = new Decimal\Decimal("1", 2); > $b = $a + $a; > PHP Warning: Uncaught TypeError: Unsupported operand types: > Decimal\Decimal + Decimal\Decimal in > > So, it appears not. > I've

[PHP-DEV] Re: Proposal: Arbitrary precision native scalar type

2023-12-12 Thread Alexander Pravdin
On Thu, Dec 7, 2023 at 3:36 PM Alex Pravdin wrote: Ext-decimal: > ... > - Workaround: implements the Decimal class that allows basic regular math > operations. > I just found out that under PHP 8.3, basic arithmetic operations on the Decimal object variables are no longer supported and cause Typ

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2023-12-08 Thread Alexander Pravdin
On Thu, Dec 7, 2023 at 11:36 PM G. P. B. wrote: - Objects are always casted to true, GMP(0) will equal to true. >> > > This is incorrect, GMP object do _not_ support casts to bool > See https://3v4l.org/LHpD1 > This is weird. Any PHP user would expect that a zero number can be easily casted to b

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2023-12-08 Thread Alexander Pravdin
On Thu, Dec 7, 2023 at 11:27 PM Jordan LeDoux wrote: You are going to run into some very difficult corners on this one. For the > last... 8 years i guess? I have been working on an arbitrary precision > library for PHP in userland. It utilizes BCMath, ext-decimal, and GMP, > depending on what is

Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type

2023-12-07 Thread Alexander Pravdin
> > Someone tangential to your proposal, have you given any thought to > implementing this similar to how Python treats numbers? > Unfortunately, I don't know many details of numbers treatment in Python... In Python, integers have unlimited precision. I’m not sure how they store > the values int

Re: [PHP-DEV] Proposal: native decimal scalar type support

2023-04-27 Thread Alexander Pravdin
On Thu, 27 Apr 2023 at 21:09, Rowan Tommins wrote: > I still don't think it justifies the "mind-blowing" and "band-aid" > hyperbole, though. It could give better errors, but the solution is still > "never initialise decimals from floats", and that would be true whatever > was built into PHP. You

Re: [PHP-DEV] Proposal: native decimal scalar type support

2023-04-27 Thread Alexander Pravdin
On Thu, 27 Apr 2023 at 07:03, Rowan Tommins wrote: > You have to load the value somehow; bcmath accepts strings directly, so > parses the values each time, which isn't very efficient; but php-decimal > uses strings to construct objects, as does GMP. I guess the other option > for a decimal would

Re: [PHP-DEV] Proposal: native decimal scalar type support

2023-04-26 Thread Alexander Pravdin
On Wed, 26 Apr 2023 at 20:52, Benjamin Morel wrote: > For what it’s worth, this is already solved in userland: > https://github.com/brick/math When I checked the sources, the first I saw was: > final class BigInteger extends BigNumber > { > private string $value; It also converts to strings ba

[PHP-DEV] Proposal: native decimal scalar type support

2023-04-26 Thread Alexander Pravdin
As a user, I want to have native decimal scalar type support. And at the same time: 1) Use a native numeric variable type compatible with other numeric types without typecasts: 1 + 0.5 (int + decimal). 2) Do not use BCMath that uses strings. In PHP8, passing float values to BCMath may lead to issue