Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93839 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77919 invoked from network); 6 Jun 2016 11:18:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2016 11:18:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wm0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:37398] helo=mail-wm0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/50-10476-12C55575 for ; Mon, 06 Jun 2016 07:18:57 -0400 Received: by mail-wm0-f44.google.com with SMTP id k204so22358991wmk.0 for ; Mon, 06 Jun 2016 04:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=gsmhe46pTmxQbgJa6zU+RYwkYAA6W8EpCwgUjkqBsuY=; b=SdMuQ/v0A2Wx8LKCyKeKk7pPr1uP+KsxyrZfQu1xWSnYoOV466UnUfVYpxRL4eBo4o lTaIWbMhmO4cEK11qMiwJQHj+3DH/6I9bAK4d3LYJxg0xpsyKGj9J8zoOJar+RyjAodq sZDyguuxW+CEGYoRaMIUlvK340VonI4JdmpHra5qcOYOgy08LrwK5i3sWkxvFH41c6ef OMXcfaEXP2wB8zk+nMepGdu850+e2d6jBvAzavsipMdGXn0Opvw3lj8tyFJcQZYl6Yff KbRCt/yQ/LRtskBtezJz4ryOGA9mTyJMQMSFtSmQzLMD/YX+jFiAYo95YKkYCousz9ri d8sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=gsmhe46pTmxQbgJa6zU+RYwkYAA6W8EpCwgUjkqBsuY=; b=Gl56WIm21H8ZzgEIRxwpg25eV9vP3gFDqWy67AI6yOPuh04UGDpuQZ8CwCqj2ozBeb wNW7Y8+0kAFMT9E+plOIAUFVTHtrIlWTAyOkyj3ta9Nl68dalr8MH/5V5CpSC2GXGbGb bRoCB/E1aLwV20h+M9bkdUKq4aRJvjuG/bIaWXWeYxc/Fu6caFUyDTtCfQRXertfXS6i vmEb8Qzg4zLS5TLdU5bQOUVKt4/F9jVV8cmoHVXHL0rOIagcaCtutrEiNofMSt7pG5N6 W01UFkExDMUx2oJK7gYg0RuMLmYkSvJ1u9jO+7okOtfbDNSXpxH6t4wM9fRdSgnL0e0F HHHA== X-Gm-Message-State: ALyK8tLBxwnIguPHQL0r5SIcHanwg5U+ISEeIRzEBfPu9tzoKcAFltMk/hK39dtGc9ZbLw== X-Received: by 10.194.169.37 with SMTP id ab5mr14991831wjc.141.1465211933500; Mon, 06 Jun 2016 04:18:53 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id b1sm19728315wjq.25.2016.06.06.04.18.52 for (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Jun 2016 04:18:52 -0700 (PDT) To: PHP internals References: <8b3055e5-706d-ae5e-bbe6-de6ba292ca5b@gmx.de> <9b9b33c0-03ff-c147-5105-e4f02901ce6e@gmail.com> Message-ID: <37e3870e-9fe4-af80-3e75-2751e33b1a36@gmail.com> Date: Mon, 6 Jun 2016 12:17:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Opinion on function/method name overloading From: rowan.collins@gmail.com (Rowan Collins) On 06/06/2016 12:06, Dominic Grostate wrote: > float, int and string all share the same row on an upside down pyramid, with $bar, being dynamic, at the bottom. OK, so take away the dynamic case, and assume the caller is in weak mode. Now you have a second case where you need priorities between the types. Or consider this code, which is already valid: class A { function foo($bar) { echo "A: $bar"; } } class B { function foo(int $bar) { echo "B: $bar"; } } (new B)->foo(1.5); // B: 1 Or we could construct similar examples with parent and sub-classes as the type constraint of $bar. And so on. I tried to stress that this is an example of one detail among many that would need to be worked out; I wasn't looking for a single answer. Perhaps we would need to add a new keyword (or a native annotation?) to mark that a function was overloaded, so that existing inheritance didn't accidentally become overloading. To my mind, this would add a lot of complexity to the language, and I'm not convinced of the gain. If you want to avoid dynamically checking variable types, you can always just provide separately named methods for separate cases. Regards, -- Rowan Collins [IMSoP]