Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91727 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76489 invoked from network); 17 Mar 2016 03:05:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Mar 2016 03:05:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.54 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.213.54 mail-vk0-f54.google.com Received: from [209.85.213.54] ([209.85.213.54:36475] helo=mail-vk0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/02-62552-FEE1AE65 for ; Wed, 16 Mar 2016 22:05:19 -0500 Received: by mail-vk0-f54.google.com with SMTP id c3so86534406vkb.3 for ; Wed, 16 Mar 2016 20:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=c83RoehdI7nshsvlh7ZouFYbzJtc3txKPOyhr+vPI+s=; b=UkDjI/yy0LPNRQNoH+jNsA0Ouo8Rqgpr1z5j7Wij6HwDb3Oaz9CmJTvCK7loSn3MM2 TtacvCX8qAl/bAOV9fzBxkFOorsIV3cNCUOqtiMy0jzc6ksV6OWCDxmC4wMd4VSS9y78 TMVYvCrkPMmUG/hixXer7cnfPBhHMSkd04Ccl5wb/HPW1y0zFfpDS00CW8jlZhdG6rwu +26/zhd9N58/g3oXRrMmuqz1gr0fdUvR8jweTufV6D+C51m6nWtmSMBfBabYD/7llfyl 1UpyCXXFZUrT8UQecatCIsCikM3ZRn1cBf9FfLx2EIzGu5TXz+Z50j6g4dUCoYcbuzTD X6+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=c83RoehdI7nshsvlh7ZouFYbzJtc3txKPOyhr+vPI+s=; b=IjpPW4frCNPyH8KdIZnJDiirRORHKttaY7vBFLh359YolKgTYktWJ5qEKmCy6yKPhd EV4/ENakcSOllq3cvN0hmh/Y9hzOstcI5e5xja4SD5QfxDa4QDvgYQeK3PkAb9EBs5w4 glYGv6hLHArL7Bcpd9SHYG+gpZErpv2cs5SAWZAg2p1oqFMJLLcg0SDQG3mJLeWIhNsS dMH6fRxW2Az/93jc7BRtURj6UiiAr+G/xoTYmmU9B5q4agleh62W2XHdONlinEJoQIjt 66FO/N1FsquCY+/wBfcSbFrhsB/b5LXmgBH46+GJ6EA0Nsz5yD56VWwZ9dJ3n2cO1otn 1opQ== X-Gm-Message-State: AD7BkJIVa/sVwhB3gD0wB3KQluAGiiQTdbwQzb0VSCBBLDvtvH9Q0wX/82KXV4Vg4bDpU093fAEUDcI//9yN9w== X-Received: by 10.31.168.76 with SMTP id r73mr8804347vke.117.1458183916609; Wed, 16 Mar 2016 20:05:16 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.159.35.77 with HTTP; Wed, 16 Mar 2016 20:04:37 -0700 (PDT) In-Reply-To: <56E99E97.2050102@fleshgrinder.com> References: <56E99E97.2050102@fleshgrinder.com> Date: Thu, 17 Mar 2016 12:04:37 +0900 X-Google-Sender-Auth: KMoebvcz2tGDNs2UnVPKc_PI2D4 Message-ID: To: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Libsodium (bump) From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi all, On Thu, Mar 17, 2016 at 2:57 AM, Fleshgrinder wrote: > On 3/15/2016 11:02 PM, Yasuo Ohgaki wrote: >> Hi Scott, >> >> On Wed, Mar 16, 2016 at 2:40 AM, Scott Arciszewski wrote: >>> Question: If this extension is adopted, which syntax would you prefer? >>> >>> \Sodium\func() >>> Sodium::func() >>> sodium_func() >> >> I prefer both of >> >> Sodium::func() >> sodium_func() >> >> IMO, we are better to provide both OO and procedural API which have >> identical features. i.e. I prefer multi paradigm programming language. >> It would be natural for PHP since PHP was born as procedural language >> and evolving as OO. >> >> Regards, >> >> -- >> Yasuo Ohgaki >> yohgaki@ohgaki.net >> > > Providing both only makes sense if you receive an object on which you > can perform more operations. It is a different situation if everything > that the extension provides is always a function in a mathematical sense > (same input produces single output). I love multi-paradigm languages but > that does not mean that everything needs to provide every paradigm; you > actually end up with a mess in such cases. We have good examples where > it makes sense [1] and bad examples where it makes no sense [2] together > in a single extension. The major reason to provide an object is to > encapsulate some information and/or state that you can pass around > (dependency injection) and that has some kind of behavior. This is most > certainly not the case in [2] because it consists only of previously > mentioned mathematical functions. [1] is different, it can be passed > around, preconfigured with some state (a specific locale and pattern). > It would become even more useful if one could instantiate it only with a > locale and pass it around, prepared to handle multiple patterns; but > that's another story. > > [1] https://secure.php.net/class.messageformatter > [2] https://secure.php.net/class.locale > > TL;DR Providing Ext::fn() and ext_fn() for everything only creates a > mess. Decide on one way and decide on the way that makes sense. > Multi-paradigm does not mean "provide/use everything, always" it means > "provide/use one paradigm as it make senses from multiple ones"; that is > also where it takes its strength from. Sounds good to me, too. We may consider more carefully. Current namespaced names may be the best option. The only problem with this is "It looks inconsistent with existing module functions". We may consider how we are going to use namespaces for extensions in general. I like the idea \ModuleName\function_name for all extension functions, indeed. Question is whether we should use something like "\PHP\ModuleName\function_name" or "\ModuleName\function_name". I'm not sure which one is better in the long run. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net