Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114084 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87589 invoked from network); 20 Apr 2021 18:45:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Apr 2021 18:45:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 034EF1804BD for ; Tue, 20 Apr 2021 11:48:14 -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=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 ; Tue, 20 Apr 2021 11:48:13 -0700 (PDT) Received: by mail-pj1-f44.google.com with SMTP id f11-20020a17090a638bb02901524d3a3d48so353369pjj.3 for ; Tue, 20 Apr 2021 11:48:13 -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=ntGtyqK48vbzeTJ7UoM955W52pnF6OOYKKztH1l41z4=; b=mPTm4wQsbPLTo+RGxbGcS7F078uwX2UQSG6CZENWiWpMKhOypRqIbwWDvsIGkh+9vG qe4un9TcgUqW3uuZQ4Isz9KbJQ4rUeEjQufRMreVig4zvr8uK5BWXCiMOqQQgWiybeHA NSit6yABqFbFkvDISC4fKYro5YyQoewo1+5ejxZkCzvC3TUvwrh76X1ejlquf7ezSSGr 0eE096ZBoQIyqJjVpu4gSZ5YZ9Ut8SEZHYpZh/2H1mcUpPN/R6FIUNnYXh2s2UyZvqsh rINlXMcGkdXfUK1kWWqPKrC+uf8EkhnC5PNb8FSNnOMq9WXFrvOQ8cW+kWPPCWXV6tbg byZw== 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=ntGtyqK48vbzeTJ7UoM955W52pnF6OOYKKztH1l41z4=; b=U43dORxOW/lB1n9tgUGWfoCPVjUFiefb8k2NCmxbxSSVkw15y4Obub1PvXEc8pHHo6 z8xwphtR9hMx21Dox9nS9UaGSI9f2YmrPfbe7LZZMno1Xuy5uWCtA7u2ejuMUDmSqWUH SLq1gygiXhvNVUGSN3juzx0XwM89UR6ZAx/W44EVRIBJqhNXjqM61D083qJ0d4BNCb9L LVrrsTZ9KkrAomobNgTYXjzZizFbfs+IFieXLtJ1G4mC/tVo60nXK+Ny6R/ImU3jBbrw bYMT/eQGcoGmTZk93uYTHoHVG48L57Ny7UMMZHTWkichZ3PJXH5XaHMuPW08xMFvBaa8 5gMg== X-Gm-Message-State: AOAM533QK7M2HyO4S6yAI0Ed3t0BDirR2y03mQCc0p+TRXUQE6WFwnge bbLRsj+cnFxu97gRUoHg/cbWBzGzo1cRgJFYxE9jYx6Ey23aIQ== X-Google-Smtp-Source: ABdhPJyOfLaV06Amrm35P81HC5OJJw06zeTGtYU9rMbHNPcyMNufSY5o2vz5X5jEcAI/3TJQhGrYi/5lPyY5SS/F73M= X-Received: by 2002:a17:903:304b:b029:eb:4cf:8321 with SMTP id u11-20020a170903304bb02900eb04cf8321mr30293607pla.40.1618944491692; Tue, 20 Apr 2021 11:48:11 -0700 (PDT) MIME-Version: 1.0 References: <918bd585-0a5a-063d-7d4e-c89eadef0dde@processus.org> In-Reply-To: Date: Tue, 20 Apr 2021 20:48:00 +0200 Message-ID: To: Pierre Cc: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000056a6e705c06be35a" Subject: Re: [PHP-DEV] [RFC] [Discussion] Adding return types to internal methods From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --00000000000056a6e705c06be35a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > Yes I know it doesn't have it, it was a subtle way of asking if one day, > the compiler may have inferences capabilities. I know it's not really > possible until it continues loading code dynamically at runtime, but in > some scenarios (such as preload, or inherited/implemented class type > checking) it may be possible, I'm only hard guessing here > Preloading can help a little bit, but still, the possible return types of all the calls have to be inferrable at compile-time in all the affected code paths. It seems pretty much unfeasible for me in most of the cases. Return types being added automatically really looks like inference > already, just a simple one, I guess. Indeed, internal method return types were "inferred" based on their implementation, but this was done manually, and we documented them in the so called stubs. It's also an extremely slow way of "inference", since the whole project took more than a year. ^^ > I'd love it. In all inheritance or > interface implementation scenarios, it seem possible, since the compiler > needs to load the implemented or inherited class code to be able to > compile the current class. > If return types were added implicitly, then you would get a diagnostic each time a function returns an incorrect value, so the error log messages could easily go out of control. Besides, you would also need a good IDE to be able to know the exact return type, which is a bit cumbersome if you only scroll through the code on web platforms like GitHub. M=C3=A1t=C3=A9 --00000000000056a6e705c06be35a--