• glibg10b@lemmy.zip
    link
    fedilink
    arrow-up
    2
    ·
    2 days ago

    Like all of the footguns in C++, it’s only a problem if the codebase uses it wrong. When used correctly (i.e. only when behaviours mimic built-in types, and without side effects), it helps makes code more readable

    Don’t do what numpy does, which is to define * for two arrays. Without learning the library, you wouldn’t know whether this performs element-wise multiplication, matrix multiplication, dot product or cross product. Worse yet, it behaves differently to Python’s built-in * for lists (which is also bad), which concatenates N copies of the list