List replication operator

bartc bc at freeuk.com
Fri May 25 12:43:51 EDT 2018


On 25/05/2018 17:11, Alexandre Brault wrote:
> 
> 
> On 2018-05-25 11:40 AM, bartc wrote:
>> On 25/05/2018 16:27, Chris Angelico wrote:
>>> You're way WAY too late to debate the matrix multiplication operator.
>>
>> /The/ matrix multiplication operator?
>>
>> In which language? And what was wrong with "*"?
>>
> In Python, the language we're discussing right now. What was wrong with
> * is described in detail in PEP 465
> 
>> (I've implemented matrix multiply in a language (although for
>> specialised matrix types), and I used the same "*" symbol as was used
>> to multiply anything else.)
>>
>> Anyway this is not matrix multiplication, but replication, and using
>> '@' seems more a consequence of there not being any better ones
>> available as they are already used for other things.
>>
> You're right, it's not matrix multiplication. And Pathlib's use of / is
> not division, nor do C++'s streams use bitshifting.

There's no need to be sarcastic.

The context here for those symbols is programming source code for which 
binary or infix +, -, * and / symbols are VERY commonly used for add, 
subtract, multiply and divide operations.

While some of them can sometimes be interpreted as various kinds of 
markup control when programming code is not distinguished from normal 
text, it can be particularly striking with @.

> But overloading the matmul operator would allow this feature to work
> without changing the syntax of the language, nor breaking existing code
> (since no built-in types implement __matmul__).

As I mentioned before, why does it need to be an operator?



More information about the Python-list mailing list