Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:104084
Return-Path: <marcospassos.com@gmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 25830 invoked from network); 4 Feb 2019 00:37:54 -0000
Received: from unknown (HELO mail-oi1-f174.google.com) (209.85.167.174)
  by pb1.pair.com with SMTP; 4 Feb 2019 00:37:54 -0000
Received: by mail-oi1-f174.google.com with SMTP id y23so10001764oia.4
        for <internals@lists.php.net>; Sun, 03 Feb 2019 13:18:37 -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=kigwi9ylWQkQm2xizO4LFj57QYUcD2n2bSaqqPAsClY=;
        b=WnpaWR+4l7ZLPJeZoLsHju62kMK0R+6QH7tLA+u4Zwba6o/ENIPJSyy34zcliaJljI
         EOxpc+SwAYVgCSmX16gT5iT9dJcd6lACPsKB1YSHRpHhtLvPifq79XxlJht+wa4V6mwg
         dGmtZgMme+qoWgF/TMFQ3Nv3aPKZwQ8lL23+pP50Wa5LQhh+SjixQ3TvGAnTG91e9ynI
         kWlHLmmzDREnqZtqNzSb1gdh0iowYryVmHiLic/JhvmC06HqziIGkwNM77LZTZ2vPVif
         o6jtGqh13e7ATY1vWpQMp8euY+Vun0QFupURg/JSGaoItp0+0+RoiPOl2m+dgcrcF04s
         o2sw==
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=kigwi9ylWQkQm2xizO4LFj57QYUcD2n2bSaqqPAsClY=;
        b=eJ184tvrpebxI28lDsf9rykAHcypQIC9ZANx6A3iizJ1Po5Z5P2WbqWraoflbf6msE
         zom/mPi9ldUu8bcftjm3KbJKLQZ992sJsu6Fn4LEJZLX6OvdgdxxUMlWJkNMJCrOs2sZ
         /VrtJeytpoYz1inYkB4sfy2iy0Bx7VhnK6VP/DLABTdrDFrpYcHt/0zD3eNww5vk260c
         uPnJwBIUOUkpbJmFJvumOSpCJVGwa8m4dIMgkUiw373eMERdSnefnPSaaDu6VzyEt6aG
         cbS6958+IgPC5SV4045pztC2b9L6iSSeql9e6xrSNuHFkBcFeRzWOlKkpAS/kVeOSM5a
         iNvw==
X-Gm-Message-State: AJcUukejqftJvDVT0FP4+fdjxbiiM4FG9t2K+ufLnbFI0SAiMDOWQ3aq
	5W9lUFfNVbzoWiZeZcEThs+TRSD4qz8yO33Q2+JrHw==
X-Google-Smtp-Source: ALg8bN7baTLYhKXTetBimehYp0Txl7sJdffanZY6SMl4/eB5bE+SbPSGVM/fctwcxfL824jJYuYTFVpK4Awn59WcIlE=
X-Received: by 2002:aca:c78f:: with SMTP id x137mr23392838oif.38.1549228717200;
 Sun, 03 Feb 2019 13:18:37 -0800 (PST)
MIME-Version: 1.0
References: <CAEsg9X1EU5hjiXZQHr5XTitsL1hdiFUAWVB-kOXwSGQ4FdLs2g@mail.gmail.com>
 <b6455813-07fe-8d47-0f34-61d4113eed56@gmx.de> <11367213-db84-bbdf-c125-4b105e08b8b6@gmail.com>
 <CAEsg9X2NqDhvaV2ZOq1kwMZ8V52Y_6EV84nJgs76i0SHBH7zYA@mail.gmail.com>
In-Reply-To: <CAEsg9X2NqDhvaV2ZOq1kwMZ8V52Y_6EV84nJgs76i0SHBH7zYA@mail.gmail.com>
Date: Sun, 3 Feb 2019 19:18:26 -0200
Message-ID: <CANA3DeuYbOaRu0wNEHPuq0b0FzJEGJu0FqLN_trKqwGT=wyrZA@mail.gmail.com>
To: David Rodrigues <david.proweb@gmail.com>
Cc: PHP Internals <internals@lists.php.net>, Rowan Collins <rowan.collins@gmail.com>
Content-Type: multipart/alternative; boundary="0000000000005d5b96058103eb2e"
Subject: Re: [PHP-DEV] Re: PHP 8: Method Overloading, The Ressurection
From: marcospassos.com@gmail.com (Marcos Passos)

--0000000000005d5b96058103eb2e
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I believe we can adopt the behaviour of mature languages that supports this
feature. Java, for instance, throw a compile-time error saying that the
method signature is ambiguous.

On Sun, Feb 3, 2019 at 17:51 David Rodrigues <david.proweb@gmail.com> wrote=
:

> Em dom, 3 de fev de 2019 =C3=A0s 17:19, Rowan Collins <rowan.collins@gmai=
l.com>
> 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 an=
d
> > 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 lik=
e
> 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, becaus=
e
> > there's no concept of "desired type" to choose between them.
> >
>
> You are right, in general. But still is possible identify the desired typ=
e
> if return is used as argument to a typed parameter, but I still thinks th=
at
> 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
> >
> >
>
> --
> David Rodrigues
>

--0000000000005d5b96058103eb2e--