Re: [RFC] Libsodium (bump)
| From: | Fleshgrinder | Date: | Wed, 16 Mar 2016 17:57:43 +0000 |
| Subject: | Re: [RFC] Libsodium (bump) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91702@lists.php.net to get a copy of this message | ||
On 3/15/2016 11:02 PM, Yasuo Ohgaki wrote:
> Hi Scott,
>
> On Wed, Mar 16, 2016 at 2:40 AM, Scott Arciszewski <scott@paragonie.com> 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.
--
Richard "Fleshgrinder" Fussenegger
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc