Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93842 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87166 invoked from network); 6 Jun 2016 12:47:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2016 12:47:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=codekestrel@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=codekestrel@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: codekestrel@googlemail.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:35304] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/D1-10476-2F075575 for ; Mon, 06 Jun 2016 08:47:46 -0400 Received: by mail-wm0-f53.google.com with SMTP id c74so44441955wme.0 for ; Mon, 06 Jun 2016 05:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=ygvbsYtMESBMbqzKsMoKQMnkzBGKKkE/bsxqvwHgtZA=; b=vEXlny2TTL0uTvc0DcvLTIiy1lIM5jSRmxxUn18eaBcglq8RV4+dkhqqBvV9gaMpn5 I0hqYMT9SJqUKYT4UfXOBwhHemhcgRy2g6t0ERELOLi7YRq2/vwu99owsIEBldpP9AoM TWr9QjYZtmHl8j3ZpfmamLJjiobuFIPt9xVE6VOyXDyc1OqjjL+8tD36ofJhRzbn454D q6zL7Lc9y/79FdfIh72PvofmFBl4X2uLoUAIOmDwsmbWoR1Ol+PzDAXUJ2k+dagiiHSl 4gZp4hqu1GUCgNWg5UM89qC1X+bAxXRCx8pCW0VxcAEHqN3MNnw161bqXxIvO1Qob9cc 0W6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=ygvbsYtMESBMbqzKsMoKQMnkzBGKKkE/bsxqvwHgtZA=; b=JKzaEUjrlveXTFEn5hxMlC+d02iIgXW/xmpK8p9/yl1OQ2j66VWcoHZUVmlFCTOUs5 4APjkxCSGKgJQ7RfQzMA7AnCfqpaywpnkNrxikLLnlNypN3gzckCImBeFsC1wtJkP+Ll cs4DKTx2/HhYBkkyQUray+3akiW9/VHsUB1h/uARsyNypER1FeGXQaPahEoikHLEygRw k2VrJu4ACy2ihxKYgdZDilETqq1Bz7BotoVUcT5be1heJ/u3tJpK2+dg7KMzX5mqB79P bI9clrUFjuE7VVcGnUMi39idZfOQ8pf7FC6VURmC8vnAg5f5/cihtxUKBM36rC251gGg KFsQ== X-Gm-Message-State: ALyK8tJIRzoLtHncShASfb7MSDtw3X5nIg78XAFoFq97gAu2ygN9WDdv8/S4qIxSHk5zdSxdR1KWjHDB8sMi0Q== MIME-Version: 1.0 X-Received: by 10.194.116.69 with SMTP id ju5mr15427248wjb.101.1465217263030; Mon, 06 Jun 2016 05:47:43 -0700 (PDT) Received: by 10.28.130.2 with HTTP; Mon, 6 Jun 2016 05:47:42 -0700 (PDT) Received: by 10.28.130.2 with HTTP; Mon, 6 Jun 2016 05:47:42 -0700 (PDT) In-Reply-To: <3B.01.10476.B3865575@pb1.pair.com> References: <3B.01.10476.B3865575@pb1.pair.com> Date: Mon, 6 Jun 2016 13:47:42 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary=001a1130ccf07b584905349b7a29 Subject: Re: [PHP-DEV] Re: Opinion on function/method name overloading From: codekestrel@googlemail.com (Dominic Grostate) --001a1130ccf07b584905349b7a29 Content-Type: text/plain; charset=UTF-8 Thanks. I only wanted some quick input into whether it was worth pursing before I do something daft.. like build it :) All I wanted to know was, if the technicalities could be worked out, and a performance boost was possible, would people still dislike it. I'd still like to see it added, but I admit it was a long shot. Thanks, Dominic On 6 Jun 2016 1:10 p.m., "Andrea Faulds" wrote: > Hi, > > Others have already raised good technical points (performance, how to > distinguish when we have dynamic/weak typing), but I'd like to offer > another argument against it, that is, that even if it were possible we > might not want overloading anyway. > > From my perspective, function and method overloading in languages like C++ > or C# is useful for mainly two reasons: allowing omitting unnecessary > arguments (or, allowing providing additional, more specific arguments), and > accepting multiple types for arguments. > > However, we already have solutions for both of these in PHP. PHP's > functions and methods can have optional parameters for which you do not > have to provide an argument, and because PHP is dynamically-typed, a > parameter can accept an argument of any type (and within the function body > discriminate between types) if it needs to. Also, PHP has fewer and more > generalised types than some other languages do, so where a C# method might > have overloaded versions taking a UInt8, UInt16, UInt32, SInt8, SInt16 and > so on, an equivalent PHP method might only take PHP's single universal > integer type. > > Of course, this doesn't perfectly cover all the use cases of overloading. > You can't, for example, directly express in PHP that a function takes one > argument or another, but not both. That said, however, I don't think this > is necessarily a big problem: you can write two functions with different > names. > > Having to write differently-named functions may well be a good thing, too, > speaking from having had to deal with APIs in languages where a "single" > method can have more than a dozen overloaded forms, each behaving > differently, yet they all look confusingly similar at the call-site. > > Anyway, thank you for asking! > > -- > Andrea Faulds > https://ajf.me/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a1130ccf07b584905349b7a29--