Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127424 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 917C31A00BC for ; Thu, 22 May 2025 10:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747908576; bh=XPk6yjvwedhrXrvpiJ4RZ8WJbG9YO68yghoas1Koym8=; h=References:In-Reply-To:From:Date:Subject:To:From; b=DbM9gNZg7DeMJfliuYBq6rYFA7H/u8xXqm/QiowY2eAFjRRzXFPMkvnwDOOtonN9H ql/HwlbP6Kj8li+vY3CX8b5QLYnSt06MZpUCz2SQ6oqpCQU0ddF5KNelVTiaxmmLnP jqsokgeqRSwvvLuTmF3y9ht6T6NjZsVXk6D/SUda4P2rughIC1Sb351mO/cXrWy9Ei cOGxpmbKZH7lUAm39tXn++HPz4eDsiPLTjd3CLjANhatoqSo8yNG1aZ0u1O01SzDeS T5r4JGcry6LTSvcUJJ7sMDTFAYksuqDazz1PtcrusjUqcTePanbhqe+I+XGOnY2KNA HIh27kgyX/PPg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EBC8D180056 for ; Thu, 22 May 2025 10:09:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_50,DKIM_INVALID, DKIM_SIGNED,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 22 May 2025 10:09:35 +0000 (UTC) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-54d6f933152so12210697e87.1 for ; Thu, 22 May 2025 03:11:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grik.net; s=grik; t=1747908702; x=1748513502; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=Mp1LP6qgz1K0FRu7VR4YG0a7YWzh+7ACa0u48lhoosQ=; b=A6tUQf5AtVId1Mmz84uBMTIfYL3Mo2Acyfl7FRslwunKBnxmD+ctUO4hW2rRAAK7ls EzBwZRPoSd8MPVkQYxfe2VoIeLyy2jT5Q/y6eTERLTSUwL4NJKu5EQUI02dKWyqeJLnc kWKhe8MgHiJlfiOwS+Mv/NtkHUti1dn9/34pY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747908702; x=1748513502; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mp1LP6qgz1K0FRu7VR4YG0a7YWzh+7ACa0u48lhoosQ=; b=knMAKDYgB8OBO4ClqST89uadjfV0d++BxoazKKRwUg/qe3g/xPzYLL75HrH1QaADQu w3rbawMiVpncpFvwPgIVSL4FrSVXEEmIoa72y43FPn8LRv2ujFpWanyyoNmDUwR0JzWZ eKVjfogt7s1T6MKmBcJDvDfdJfCj2xzFqEg7wZwVMul6IJg+R/liiCsIkD8Ykd/FiwKj t6zJovR2SWb9LfPeg0J0X/XmrXooe6iDZk6dtGetvUFiXB94VVAJ2W2rOHY7alEvwrbA GH9/gLYxOhKOYegK9wR/2aya+c9bTK8qQC10UMAryAPW42HSg3UG/MmTsefb2OUXHCcN qqaQ== X-Gm-Message-State: AOJu0Ywv7uXaj+nRogjGif2jPa7VCt3SrNWe0f0SLuv4OVxdBkWpqmyb DgCR/oEkwu1QvSZqPUzigeV9wrRzLcWSyqzz9VSVrhjNNPBAoejl96yrCzcmhGQM5WiobawvdMr 3RoCw8rNxuL9ZQVD2rKjBNkHw0NZ3m/gaUrq0J05q0x0HLSW3frN5STg= X-Gm-Gg: ASbGncss0s8p20ZJpZVNN4XHUx+LMIP8AqUYkbTVu3h+okzmS1kXFjywOBKQSZn1riY KmdtesyG+IAsJVARdxXhq/0h4UIOA5n/lS4XBswO9gPwotoWepXh+rAhLtwFnlokyHAsWqUeSRs g4zWFEFTDWrJHbbLEmDAJMykJMO/tAKJE= X-Google-Smtp-Source: AGHT+IHnqS2LoVs3Onqa7qArUMwGw8l+v2p8y1XsktyGhZ2/FUByaGZDP7W5tGonz5sLlsRQIcabXBF8PxjOI8iEoVk= X-Received: by 2002:a05:6512:6515:b0:550:e31f:1d2b with SMTP id 2adb3069b0e04-550e971af30mr6256917e87.7.1747908701629; Thu, 22 May 2025 03:11:41 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 22 May 2025 12:11:27 +0200 X-Gm-Features: AX0GCFvdxgyIc6rhItDbOl0prvNC5dlQ99lxV-QT5XZm_ItVoR3swF0BTLyCeyU Message-ID: Subject: Re: [PHP-DEV] Generics - Userland implementation via attributes (released today). Discussion and seeking advice for improvement To: PHP internals Content-Type: multipart/alternative; boundary="00000000000042c2a70635b6b560" From: grigori@grik.net (Grigori Kochanov) --00000000000042c2a70635b6b560 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Grigori Kochanov 11:25 (32 =D0=BC=D0=B8=D0=BD=D1=83=D1=82=D1=8B =D0=BD=D0=B0=D0=B7=D0=B0=D0= =B4) =D0=BA=D0=BE=D0=BC=D1=83: Arvids > Hello Internals! > > My friend Grigory has cooked up an exciting package implementing generics > with full runtime type checking in userland. > I honestly believe it can be surpassed only by doing a full native > implementation (which we know is fairly unfeasible from Nikita's previous > research), it's transparent to the PHP code (if disabled, the code will > still run just fine), is pretty light performance impact wise and require= s > zero pre and post processing (aka "compiling") of the code. It's as > transparent for the developers as possible. > > https://packagist.org/packages/grikdotnet/generics > https://github.com/grikdotnet/generics > > List on what's implemented and what is possible: > https://github.com/grikdotnet/generics/blob/master/documentation/story.md= #implemented > The documentation folder contains quite a bit of information :) > > I'm posting this to internals for the following reasons: > > - * Seeking advice and know-how on how to improve performance > - * Ideas on making the syntax better > - * Explore the possibility of making changes to the PHP engine > - Improve performance > - Support extended syntax in the attributes > like #[\Generics\T(Collection)] so it doesn't have to b= e a > string that needs to be parsed as it's now > - Return type attributes? > - How about having a built in generics empowering attribute that > userland libraries can take advantage off and do implementations? > - Having an extended discussion of the feature and where it can be > taken going forward > - Seeking help with implementing missing features, code review, etc > > Grigory has signed up to the list, so you can direct all the questions in > the thread to him :) > > Thank you Arvid! My intention is to attract attention to generic programming, to prove that it's partially possible, and eventually see the implementation in the engine. What is missing for the system-type solutions is a way to break the encapsulation of objects a legal way, rather than with a known hack with unserialize(), and to override the "final" statements in the non-userland code like a testing suit or a system-level library. The return type attributes would help implement generic types for return declarations. Quoting the basic types in attributes is actually the limitation of Nikik's parser, not the PHP engine itself. I believe it can be done if there is a demand for it, as well as the performance improvement. The feedback and questions are more than welcome! WBR, Grigori --00000000000042c2a70635b6b560 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Grigori Kochanov=C2=A0&l= t;grigori@grik.net>

11:25 (32 =D0=BC=D0= =B8=D0=BD=D1=83=D1=82=D1=8B =D0=BD=D0=B0=D0=B7=D0=B0=D0=B4)
= 3D""
3D""
=D0=BA=D0=BE=D0=BC=D1=83:=C2=A0Arvids
<= div class=3D"gmail_quote gmail_quote_container">
Hello Internals!
My friend Grigory has cooked up an exciting package implementin= g generics with full runtime type checking in userland.=C2=A0
I h= onestly believe it can be surpassed only by doing a full native implementat= ion (which we know is fairly unfeasible from Nikita's previous research= ), it's transparent to the PHP code (if disabled, the code will still r= un just fine), is pretty light performance impact wise and requires zero pr= e and post processing (aka "compiling") of the code. It's as = transparent for the developers as possible.


The documentation folder contains quite a bit of = information :)

I'm posting this to internals f= or the following reasons:
  • * Seeking advice and know-how o= n how to improve performance
  • * Ideas on making the syntax better
  • * Explore the possibility of making changes to the PHP engine=C2=A0
    • Improve performance
    • Support extended syntax in the attri= butes like=C2=A0#[\Generics\T(Collection<int><float>)] so it do= esn't have to be a string that needs to be parsed as it's now
    • <= li>Return type attributes?
    • How about having a built in generics emp= owering attribute that userland libraries can take advantage off and do imp= lementations?
  • Having an extended discussion of the feature and= where it can be taken going forward
  • Seeking help with implementing= missing features, code review, etc
Grigory has signed up to = the list, so you can direct all the questions in the thread to him :)
=


Thank you Arvid!
My intention is to attract attention to generic programming= , to prove that it's partially possible, and eventually see the=C2=A0im= plementation in the engine.

What is missing for th= e system-type solutions is a way to break the encapsulation of objects a le= gal way, rather than with a known hack with unserialize(), and to override = the "final" statements in the non-userland code like a testing su= it or a system-level library.

The return type attr= ibutes would help implement generic types for return declarations.

Quoting the basic types in attributes is actually the limi= tation of Nikik's parser, not the PHP engine itself. I believe it can b= e done if there is a demand for it,=C2=A0as well as=C2=A0the performance im= provement.

The feedback and questions are more tha= n welcome!

WBR, Grigori

=C2=A0
--00000000000042c2a70635b6b560--