Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111887 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12213 invoked from network); 17 Sep 2020 17:52:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Sep 2020 17:52:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B2F06180553 for ; Thu, 17 Sep 2020 10:01:36 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 17 Sep 2020 10:01:33 -0700 (PDT) Received: by mail-ed1-f52.google.com with SMTP id ay8so3231360edb.8 for ; Thu, 17 Sep 2020 10:01:33 -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 :content-transfer-encoding; bh=r7uQsSG79egHj8rxBqJC6scgTV72FbtIVydsXKHEcGo=; b=EQM5Unbg+pIy/3CurORhVwe4ke7J5RgGBiavowSjLOD2qt59nZzX3kYOU15GANOMUO Z4d7CsqX987eg0znnvzsKV1eQZoTlT+y/pP/L6V8iR/VGY3pb9eoa2RrFpxnxq2jtHe2 s9PvwBZcqi1qw4uzFggaBCPfn/+8NkMc5dzJXvXyIl8wYUNKkfkEwMsOT/aswuB7ECuZ QNq+qmqxr0Z7ln6faxCgjyobRCGgyhbYX8WPYzoI3hFD/6zs6XoJtDrk1mKb3is9zVMs 6wwpLWlr3VrIWaqG2zKMB763MvOxvIZdYfWdEdY3F0o0d4aenv3IhOO9ZFRxowtaV1e8 vxlw== 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:content-transfer-encoding; bh=r7uQsSG79egHj8rxBqJC6scgTV72FbtIVydsXKHEcGo=; b=ZwD4EXAG7ZpNDlejagOcuctuEZ6TWkCV3aplRFA8+p38jR2jNQuLV5pVYIX3zU2yZG wgFxdSmF3cIPmYd5adIqbD7uSwoLY4OSA7AqhlI+7mhUjRsev7217ysdQ4VaDjbjQbQq CRv2BjjIOKl0F9SZ3xLBm8JBfDDRt5b3/lqLMux5DpCKUIaAfOsPfiJLaYWG+c5ooL8C 0AxLdfpF1EHNBvEh02+EgRR7DBoh65R8P0Mj4r3gwzMQneII6heejn14jnCuO1f9mCFj KvzPLObhNqn9Ma5vTYqpvykrYgUm4gZmWI1UTypYQmBfBlkzMhDxRtn/h++/EGMJ1A66 d+Dw== X-Gm-Message-State: AOAM532xy3OQUXia5h2dnGojak7GN+iyHPKIo+3DiWqcak70gAe8vJrB b7m5B+j6Qga1Xse+IoQbuLZcAofboRiI1jJmiSbPoZTPrPc= X-Google-Smtp-Source: ABdhPJzy1vlsGPnEz16xZf+O1KWO80rAzEj5gaPrEiZ6d9HVMXeGL+U6Jg7uRu/lT592Ep2S+tEA4nxLH6/4vN5PMGM= X-Received: by 2002:aa7:d353:: with SMTP id m19mr32968478edr.275.1600362091612; Thu, 17 Sep 2020 10:01:31 -0700 (PDT) MIME-Version: 1.0 References: <09DE673B-71B7-4C8E-A795-900B51F8E476@stitcher.io> In-Reply-To: <09DE673B-71B7-4C8E-A795-900B51F8E476@stitcher.io> Date: Thu, 17 Sep 2020 19:01:19 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] The case for transpiled generics From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Brent > Today I'd like to hear your thoughts on what might be a controversial top= ic, though I think it's worth having this discussion. I want to make the ca= se for adding generic syntax, without actually enforing any additional type= checks at runtime. Please hear me out. I think having the option to omit runtime type checks could be valuable even for non-generic code. If your own internal classes all use static analysis the chance of passing a wrong type is pretty low. This would probably have to be on a per class or even per function basis as you can't reason about other people's code. I do think we need some form of generic runtime check. If we don't, how generics work is completely open to interpretation. Static analysis tools copy the behavior of PHP. If PHP has no behavior in this regard tools will deviate and generics won't have any real meaning at all. There are many nuances to generics (ask Matthew who wrote Psalm), we shouldn't underestimate that. With a hybrid approach we could also do full type checking in testing environments and disable it in more performance critical situations with more confidence. Ilija