Re: [RFC] Comparable
| From: | Ryan Pallas | Date: | Tue, 31 Jan 2017 23:02:07 +0000 |
| Subject: | Re: [RFC] Comparable | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98101@lists.php.net to get a copy of this message | ||
On Tue, Jan 31, 2017 at 3:48 PM, Fleshgrinder <php@fleshgrinder.com> wrote:
> Hi :)
>
> I have a few questions regarding the comparable RFC:
>
> https://wiki.php.net/rfc/comparable
>
> Couldn't find the thread in my history and thus cannot respond directly
> to any of the past threads. Maybe not that bad after more than a year of
> silence. :)
>
> My question might sound silly but I am genuinely interested in the
> explanation: why
compareTo and not
> comparedTo as method name? Is it
> simply because of Java? To me it sounds kind of wrong:
>
> if ($this->compareTo($other) === -1) { }
>
> Especially if we add a nice Ordering Enum with some real behavior to the
> game:
>
> if ($this->compareTo($other)->isLess()) { }
>
> Compare this to:
>
> if ($this->comparedTo($other)->isLess()) { }
>
> This gets close to what I would understand as proper English. Then again
> there might be valid reasons for the former name that I am not aware of?!?
>
I would say compareTo makes sense, because that's what you're asking the
method to do. Methods aren't usually past tense as it would seem weird.
Think about PDOStatement::fetch vs fetched, Exception::getMessage vs
gotMessage. Honestly I can't think of a single example of a past tense
method off the top of my head (doesn't meant they don't exist!). Even
functions and language constructs are present (echo, require, print).
>
> There are other things that I think should be added along with this RFC.
> However, I need to investigate a bit further first before going into
> detail here.
>
> --
> Richard "Fleshgrinder" Fussenegger
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>