On Sun, Feb 3, 2019 at 3:54 AM Adrien Ricocotam
I think all the issues you have right now would go of using another operation. I proposed the @ notation that is clear and different from everything else,
plus the operator is called "matmul" so it completely makes sense. The the
examples would be :
l = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split() v = Vector(l) len(v) 12 v @ len
I cannot really see how using the @ operator helps anything here. If this
were a language that isn't Python (or conceivably some future version of
Python, but that doesn't feel likely or desirable to me), I could imagine @
as an operator to vectorize any arbitrary sequence (or iterator). But
given that we've already made the sequence into a Vector, there's no need
for extra syntax to say it should act in a vectorized way.
Moreover, your syntax is awkward for methods with arguments. How would I
spell:
v.replace('foo', 'bar')
In the @ syntax? I actually made an error on my first pass where simply
naming a method was calling it. I thought about keeping it for a moment,
but that really only allows zero argument calls.
I think the principled thing to do here is add the minimal number of
methods to Vector itself, and have everything else pass through as
vectorized calls. Most of that minimal number are "magic method":
__len__(), __contains__(), __str__(), __repr__(), __iter__(),
__reversed__(). I might have forgotten a couple. All of those should not
be called directly, normally, but act as magic for operators or built-in
functions.
I think I should then create regular methods of the same name that perform
the vectorized version. So we would have:
len(v) # -> 12
v.len() # ->