Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72236 invoked from network); 6 Jun 2016 10:32:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2016 10:32:43 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.20 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.20 mout.gmx.net Received: from [212.227.17.20] ([212.227.17.20:49959] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/F1-60933-94155575 for ; Mon, 06 Jun 2016 06:32:43 -0400 Received: from [192.168.2.102] ([217.82.228.97]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MC7em-1bIhXR3yHg-008vjo; Mon, 06 Jun 2016 12:32:38 +0200 To: Derick Rethans , Dominic Grostate References: Cc: PHP internals Message-ID: <8b3055e5-706d-ae5e-bbe6-de6ba292ca5b@gmx.de> Date: Mon, 6 Jun 2016 12:32:49 +0200 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 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Cd7hUgSxNtPkphwUu4HLp4gTpPA2Gt/y+JrxOf7qAeEfsunmFy9 jBSX6+aCIjGWE8Ay7R5OHy+fLaeIhUU8vRcqit0jSTJOQu9A9vAmOvdR4ZXFSvpryEmTH8z dtTS+NFMJ1KfbwLZNzMwYtWujNfG38bDpyICwbmI8DS7EENHsf5oPibowGsuw7AMneyM1eX 32qZFWd6jE3/zrZ7xWe1g== X-UI-Out-Filterresults: notjunk:1;V01:K0:Uykll1j53D0=:3ZhZGpF1NRowBsqVlXA19F 7hrv2JbdDiwyIZQ7tutsCYn9uU1HJu+y7aFffVUutyhYrSxY9+QsUa/k7od0b86SaSYOU29Gl orqcpvCUVAhruuFV4YmQBsmxheFVH9IPW9vG1yMZh8tp9lQD0d/xCSmdFLRLDaQZOYoc2XUhJ P82dwAo75u7jZXdU2IZf+F3dNX5jE22jXyEhV6SCXDFgnj9A+V41nQ1lAp4lhuy7z1IILjOlz liILalNZjakD0Sg3wt2R+ZO7yt9Qtm8J216Y8xUqFxct+h55uU42FPDeNel8ydVGdGlV1YgfD KBbLFD6nmQSswNwIzmFgi7rdhrNFvffX9nfifW87OURtq3Q2EffNAgWWVPnFD0cOcHHBOphvI MF7SPbA7X6OGyZjyfo5DpHkz+AesTH9XaXNnNO7RVFvc1cvDaZpxt64dsz6dAhugfm1nfcoGc cnBwFBCv82NujoS/C7vsSBlIzPK/U4iJk6phfJ9qPx+YHAY88aiCEV4h83UmPVGQMJzyhZ/ql BDGqLPQ1Ab7MJm0o3JWe841snRwUQCSx4m00gmPsk2FJtDcITNB+B8H0/olOvPsV6So02N20/ np9wJUnzdpiRy1tH7AwHWaTU0g7waBakSCSOd9JVNJSKzTFi+dgcaKAsDOryeb8eznDQlWI3H CSoFfyzktNWcsF+Ybj11+speZAi0+N8CyVa5P1s3IKnFKMoPG+3HsQeP6vcLtetafY31VmtOJ P03rllt9sD4kwQRf5FZkZ/7LlWl7xWiFqDmJDXKJR6oGNk1XdhhV7cAIn4un+mi8Dq/8N2DwK eeBjDZf Subject: Re: [PHP-DEV] Opinion on function/method name overloading From: cmbecker69@gmx.de (Christoph Becker) Derick Rethans wrote: > On Mon, 6 Jun 2016, Dominic Grostate wrote: > >> As I understand it, using Java-like function overloading in PHP is >> undesirable due to hindrance in readability. > > Besides it impacting, readability, it will also create a large impact on > performance. > > Right now, functions (and methods) are looked up by their name only. In > order to support function overloading, the argument's types also need to > be taken into account. In C++, it works by mangling function names by > adding markers for types, such as: > > _ZN4HPHP34c_MongoDBDriverCursor_ni_getServerEPNS_10ObjectDataE > > which means: > > HPHP::c_MongoDBDriverCursor_ni_getServer(HPHP::ObjectData*) > > But unlike in C++, this needs to be done at runtime, and every time a > function is called because PHP is dynamically typed, and not statically. > > For example: > > myOverLoadedFunction(string $s, long $l, Weather $w) > > could be: > > myOverLoadedFunction_s_l_cWeather > > or something like that. > > Doing these conversions would mean (in the most simple way), that for > each function call, a string needs to be manipulated to create the > mangled function name to lookup for in a hash, where right now, they > only have to be strtolower()'ed (because of case insensivity). > > And then you need to do something sensible when *no* types have been > defined. And we would run into similar issues as with the union types with regard to weak typing. -- Christoph M. Becker