​(Skims discussion)

For e.g. `abs(Vector2(2,-1).elementwise())`, my (C++) library instead
handles this as `abs(Vec2(2,-1))`, returning another `Vec2`. In C++, if you
weren't expecting that, you get a compile error on whatever happens next,
whereas in Python you'll get a `TypeError`, so it's well-defined.

If you want the vector's length, I use a function, but perhaps it's more
pythonic to use a method: `Vec2(2,-1).getLength()`, or
`Vec2(2,-1).getLengthSq()`.

If your vector represents a complex number and you're wondering why
`abs(...)` shouldn't return a complex modulus, then I ask why you aren't
using the built-in `complex`, which is designed for this.

Ian

Reply via email to