On 2026-11-30 22:34, Lawrence D’Oliveiro wrote:
> [...]
>
> And unlike C++, and almost like Algol 68, it can do things that look
> like custom operators, too
What does that mean? - Behind your link quoted below we can read:
"Python lets you add custom overloads for its built-in operators,
but it doesn’t let you create entirely new operators."
Overloading existing operators is also possible in C++, so what's
the actual difference (in Python)? - It seems the only difference
is to be able to provide [clumsy] _named_ operators that (compared
to ordinary functions) just avoids the necessity for parentheses.
The method seems convoluted, though, and the syntax is very crude,
IMO.
The "final score" (on the linked page) is the Python example for
the cross product (and requiring additional helper functions) with
an operator expression like
v1 .cross* v2 .cross* v3
which would in Algol 68 (since you mentioned it) probably be more
something like either (with named operator 'X'), say,
v1 X v2 X v3
or (with symbolic operator), say,
v1 * v2 * v3
or any other allowed operator symbol(-sequence). Take your choice.
Concerning the C++ case I don't see that Python would add anything
worthwhile here. YMMV.
Janis