Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104081 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4784 invoked from network); 3 Feb 2019 23:11:01 -0000 Received: from unknown (HELO mail-it1-f174.google.com) (209.85.166.174) by pb1.pair.com with SMTP; 3 Feb 2019 23:11:01 -0000 Received: by mail-it1-f174.google.com with SMTP id a6so17386159itl.4 for ; Sun, 03 Feb 2019 11:51:43 -0800 (PST) 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=W1OKceOSqyyCJKNyB7LnubqTEpt1S2UP1BNbRHTGhcw=; b=C5dy0JehlE5bmWn0X7pM+HP80vHPm7kKHyesy/3csqKVidVv1CpE3yHPGSEv7hT1uw 0WokLMsn3T7WvsA/Lwco+XjDzmYoMbpL88RCaL9taWDl7bNwYtmOOl3KVMyl3xc1w/XC eLFQifoeDIcfhfMwVlT4fELC6FOg3BFwqpiFK9jMR4IJV7W7MRs1X1+IYYx2LmqEA0av xNIyXRdO4TBV0vlz2sAHKwriESJTf9aYTZxkyB1fnROMTpyXkIcruJQ+suc5ujIRPYcZ Wva7ExyffgOCmoy/ERszcvrG1W08o5JhxDs2vN1PZ1dP/adD1guDb5KrSnWLGAi6NF2P wrrw== 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=W1OKceOSqyyCJKNyB7LnubqTEpt1S2UP1BNbRHTGhcw=; b=uGz5OsLYIkfSEWI9gdiw1wu5W7MlyxaWiPcY4YYkfwByQnbAhzs6foPuEs50diIj4h lXetV8HZ8gnb6Q15mSnJ7dHkKrSrz6gcZZA41Wnt40VYTAmJCMAVjM5Jkhv6CUrN/AOq ZlAqBPeZ5u7zTTdtQr8CW8JTqclZX5Xz4OxsWb4suS/8ppPLLVYGE6Pu9LP6uxCUjj9t Nvj7EV4/ajNdeoJrUYtK2NZLiHej5mt5swbLu+3aSG6L6VChs8on1Izmr6LpfDtrMFXL 9S8cvn/pDMCO4iKr32K2U8UDoud/gfnkKrXLv2rRGgFJzzk3JJtv6JlfMAEck1n3jihz K6pA== X-Gm-Message-State: AJcUukdYqkrpR8bj0tQF4yw3xS3qJ9YHS/Mbhjlne8G9imsgZlNDniCh Fr4V0mls1+e6l5vQceG9EFZfg3Yknot4RJVn3WA= X-Google-Smtp-Source: ALg8bN5qohqTw3s0O68p1mCk5hrO5b0h/AfI6qAuu7lDQsR27BJ2AfcVoE1Xo2wzwGOZzFFL5OVBS+wBFuwTjbthuSk= X-Received: by 2002:a02:a906:: with SMTP id n6mr28796768jam.123.1549223503418; Sun, 03 Feb 2019 11:51:43 -0800 (PST) MIME-Version: 1.0 References: <11367213-db84-bbdf-c125-4b105e08b8b6@gmail.com> In-Reply-To: <11367213-db84-bbdf-c125-4b105e08b8b6@gmail.com> Date: Sun, 3 Feb 2019 17:51:32 -0200 Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000996001058102b4c5" Subject: Re: [PHP-DEV] Re: PHP 8: Method Overloading, The Ressurection From: david.proweb@gmail.com (David Rodrigues) --000000000000996001058102b4c5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Em dom, 3 de fev de 2019 =C3=A0s 17:19, Rowan Collins escreveu: > On 03/02/2019 19:00, Christoph M. Becker wrote: > > On 03.02.2019 at 19:39, David Rodrigues wrote: > > > >> overload function sum(int $a, int $b): int; > >> overload function sum(float $b, float $b): float; > > Which function would sum(17.4, 42) call? Also consider: > > > > sum(PHP_INT_MAX, PHP_INT_MAX) > > > > vs. > > > > sum(PHP_INT_MAX+1, PHP_INT_MAX+1) > > > Yes, marking overloaded functions explicitly definitely helps, but I > think the dispatch part is more complex than it first seems. Classes and > interfaces require a bit of subtlety too: > > class Foo {} > class Bar extends Foo {} > > overload function foo(Foo $a, Foo $b); > overload function foo(Foo $a, Bar $b); > overload function foo(Bar $a, Foo $b); > > foo(new Bar, new Bar); > This example could be complex. So, what other languages does in cases like that? Java, for instance. > > There are plenty of cases more complex than this, e.g. when a class > implements multiple interfaces, and you need to find a matching signature= . > > That's not to say it's impossible, just don't underestimate the edge > cases you'll need to legislate for. > > Oh, and note that return types can't participate in overloading, because > there's no concept of "desired type" to choose between them. > You are right, in general. But still is possible identify the desired type if return is used as argument to a typed parameter, but I still thinks that it could not be done in general terms, so maybe we should not includes return type to overloading. > > Regards, > > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 David Rodrigues --000000000000996001058102b4c5--