Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113330 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63833 invoked from network); 28 Feb 2021 17:30:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Feb 2021 17:30:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 154A31804C0 for ; Sun, 28 Feb 2021 09:20:44 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 28 Feb 2021 09:20:43 -0800 (PST) Received: by mail-wr1-f53.google.com with SMTP id a18so5419486wrc.13 for ; Sun, 28 Feb 2021 09:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=wPGC6Nbs3QKYKOskw2JVCAT7sODVL9OEmuJ9/4B6uos=; b=KBwXx4Dhu0crQaYOBHg0SgHcRHwHlLIR6DaFNv1eA1q4dTQmgsveItvKX75Eje1ZxP LjScxJkI9G00QqTxz5mUMGi5RtxkBRVaWNxoTJK17uNtylL5Q0nXQ7KCZnyDCyKJyvXc 5x/fX+quExlqGbtpjlSfMPuq3QEB+KUZ9/yqnNuYH/C6e7DlcirjoH5O1GKs/VHHBK6i /pq1MJJjxE2JWCChZbt4ryag5D4Or1uKMdlaSRAz3bWH2JSNzRO2JBO/ZTkeGVCdvTUZ H9iLDilS/V5jOFkT+KLCnxKrPoqKsacA6BhSwBy56tMRsT3tT0ncs6Q8+qWc5rlj+mJY LJyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=wPGC6Nbs3QKYKOskw2JVCAT7sODVL9OEmuJ9/4B6uos=; b=qM9zPbqU0jooH5efyIgzrLRw1H/8rMpRkCuqFX7YEInIGvB8haqfl3SbJ7U4OzRMe5 pQclRCZYf6etCd9Rol73miIYESqiHsTr7ws5tNSuHhiIQzZyifRHe2trGVVD93lqt4ki ex7Uf9mvgmgoj0DsKhRnzAKaqd/fMq4uvU2GsrNSgnDQ+CeLS9933kuCuKcYyqOBwj7a L/iGePYE+aqAGkRyYuiBdlCQURuAMvIht0V5MJNMLCH2Qod5GKHxeBgqVjnihEP58i23 /pWHW9LVFRBp+ztL1ZJubwtT1RHdNZNi6AVCjxqfKHNeABUCxJu8F8V4BJij7RinQs5W XJPg== X-Gm-Message-State: AOAM532b8QM7F2AaAACcj6PJZ2zBDoa0/H+6GC9LeULNnxfuL5akalaK 4w751EdzFCL3J7WWPNLM1eUOdS5BLq8= X-Google-Smtp-Source: ABdhPJx8SlmSRFFqTuTTHJQkz831uohOrH4iH3uMSr7pBtsVdiGpI9bIBYIAElPgKj1hvop0H4OYhQ== X-Received: by 2002:adf:f78f:: with SMTP id q15mr12606974wrp.383.1614532839754; Sun, 28 Feb 2021 09:20:39 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id q15sm22427825wrr.58.2021.02.28.09.20.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Feb 2021 09:20:39 -0800 (PST) To: internals@lists.php.net References: Message-ID: <21c4b792-e9ec-c3cb-7d60-a9cbaeb5eb99@gmail.com> Date: Sun, 28 Feb 2021 17:20:37 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Methods Overloading in PHP From: rowan.collins@gmail.com (Rowan Tommins) On 28 February 2021 13:20:57 GMT, Eugene Sidelnyk wrote: >> It looks like your message is missing at least a link >Sorry, I am using gmail and have attached an image which you probably >can't >see. > > https://habrastorage.org/webt/my/8t/in/my8tin97ukibw6ebh0cbaqhmv64.png It's not to do with your mail client or formatting, the mailing list strips all attachments. Screenshots of text are probably the worst way of sharing a quote from something anyway. I don't know what the rest of the article is like, but that quote makes a pretty poor case for overloading. It has very little to do with OOP - SmallTalk, where OO was invented, doesn't have it, but plenty of non-OO languages do. There is some relationship to polymorphism, in that you can consider two classes with the same method name to be overloading that method name based on the type of "$this"; but in that case PHP does have it. If anything, overloading on the types of multiple parameters is something I'd associate more with Functional Programming, where you might have multiple overloads for a global function like add(x, y), without them being "owned by" a particular type. The example given of content(File) vs content(File, Charset) is also not great, because it can be achieved in any language with optional parameters, which does include PHP. In some languages, using overloading would save an if check at run-time, because the compiler would select the correct overload, but PHP's method despatching and type checking are all done at run-time anyway. With union types and named parameters, a lot of cases where overloading would be used in C# or Java can be expressed in a slightly different form in modern PHP. It would sometimes be nice to have multiple constructors, but named constructors are more flexible than overloading by type (e.g. Foo::fromName(string $name) and Foo::fromCode(string $code)), and static methods provide a reasonable stand-in for those. Regards, -- Rowan Tommins [IMSoP]