Re: RFC: Add `final class Vector` to PHP
| From: | Peter Bowyer | Date: | Mon, 20 Sep 2021 08:40:20 +0000 |
| Subject: | Re: RFC: Add `final class Vector` to PHP | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116102@lists.php.net to get a copy of this message | ||
Hi Tyson,
On Sat, 18 Sept 2021 at 16:46, tyson andre <tysonandre775@hotmail.com>
wrote:
> Many of php's names are based on the naming choices in libraries made in
> C/C++.
> So using https://cplusplus.com/reference/vector/vector/ for my
> RFC
> https://wiki.php.net/rfc/vector
> seems like the most natural naming choice,
> and would make it easier for people with backgrounds in that family of
> languages to find the functionality they're looking for.
> PHP already has a SplStack, SplQueue, etc, like C++'s
stack÷ƹP®
> Ù„Ã:ûWÆ, queue,
> etc.
>
That is a fair point. Vector is an overloaded and common word. For me a
vector will always default to an entity characterized by a magnitude and a
direction, because that's what I learned and used for years. The next
definition I learned was the Numpy one.
That for me is the sticking point if this Vector allows mixed types which
include arrays or vectors. Store them inside a Vector and then you end up
with a matrix, a tensor and so-on in something identified as a Vector,
which is nonsense. Yes C++ does that [1]. Yes with generics it sort-of
makes sense. Numpy gets round it by calling the type ndarray and a vector
is a specialised one-dimensional array.
If it's a high-performance array and that's the goal, call it hparray. Call
it a tuple. Call it a dictionary.
> Also, your comment is ambiguous. Are you saying that you personally object
> to the name,
> or that you're fine with the name but think that the comments by
> Larry/Chris/Pierre in this email thread are representative of voters.
>
Both.
I object to the name for what's being proposed, but am not necessarily
against what's being proposed if it looks more useful than the Spl* stuff.
I'm fine with the name but for something other than what's being proposed.
HTH
Peter
1. https://www.geeksforgeeks.org/vector-of-vectors-in-c-stl-with-examples/