Global Feed Post Login
Replying to Avatar ᴛʜᴇ ᴅᴇᴀᴛʜ ᴏꜰ ᴍʟᴇᴋᴜ

Operator is a red flag... builtin logic should only apply to values, and values, specifically, that are based on the CPU's built in types

vertical bars | are generally used as either bitwise OR or as concatenation operators for cryptographic operations, for example

but there's some nasty ambiguity there... append(first, second...) is unambiguous

i'm not gonna say anything about inheritance just focus on the point of redefining operators

many languages now allow you to redifine any infix, postfix or prefix operation on many other types

this creates ambiguity in the mind of the programmer, what does this + mean? addition? concatenation? encapsulation?

the more i have to think about what a common operation means, the more likely i am to not understand what two variables with this operatior between them means, and that increases the risk that i'm going to miss a bug

Avatar
Tristan Brice Velloza Kildaire 1y ago

As for your semantic point of view. Well that is processed later during typechecking.

A binary operator is the most generic way to describe it.

You determine the meaning based on the operands. In many cases I have used my type coercion mechanism which, I believe, coerces to the left hand operand.

So it works out well.

Reply to this note

Please Login to reply.

Discussion

No replies yet.