[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Give 1 (one) good reason not to have operator overloading in

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 39
Thread images: 1

File: 221.png (605KB, 2363x1866px) Image search: [Google]
221.png
605KB, 2363x1866px
Give 1 (one) good reason not to have operator overloading in your language.
>Hardmode
Shitty developers don't count.
>>
Why not a single method that handles all types of input by itself? If that's actually needed?
>>
>>59619675

Because
subtract(add(a, b), mul(c, d))

Isn't as readable as
a + b - c * d
>>
Clarity maybe. A function might be clearer whereas stumbling upon an overloaded operator while reading some code could throw you off and might send you inspecting a completely different part of the code to understand (or make sure) how it works behind the scenes.
But I'm a shitty developer so I don't really know.
>>
Order of operations brings in complexity in both design and implementation of the language.

(LISPs solve this problem with prefix everything)
>>
>>59619825

If you are overloading operators to perform operations that are not immediately recognisable as some obvious add/subtract/index etc. analogue then you're just a shitty developer writing shitty code.
>>
>>59619872
So removing operator overloading completely from the language could potentially make your life easier when you're working with shitty programmers.
Good programmers being pretty rare I think this is a good argument against operator overloading. Of course this is meaningless if you only work with talented people or alone.
>>
>>59619924

Might as well not even have inheritance or OOP in general if you're worried about shitty developers abusing useful features.
>>
>>59619646
I have never overloaded an operator in my life even tho the languages I use have it. What kind of weird abstraction are you working with that can't be done better with better use of generics and functions? I have never wanted to overload types that don't already support arithmetic operation by default.
>>
>>59620008

>I have never worked with arithmetic types that aren't primitives
Maybe one day you'll meet a vector or an arbitrary-precision real.
>>
>>59619957
Then may as well remove variable names and just use cells like in brainfuck since they may use shitty variable names. May as well use opcodes instead of user defined functions since they may make ones that are innefficient and don't make sense.

No matter how many useful tools you take away because they can be abused you will still have capacity left for shitty programmers to be shitty.
>>
>>59620086

Exactly. So why remove something as useful as overloading?
>>
>>59619646
It's harmful as FUCK

how is
"string" + "string"
intuitive at all? It's a string, not a number

also bad for performance reasons

only nu males working on meme langs like op overloading because they have zero regard for code correctness or performance in the first place
>>
What programming languages should do is support basic arithmetic on vectors or bignums but not have operation overloading. Then all these retard would have literally no arguments for operation overloading.
>>
>>59620277

OP here, I'm satisfied with that. Anyone trying to overload +-*/ on non-numeric types is a shitter.
>>
>>59620257
>also bad for performance reasons

How so?
>>
>>59620036
Why would I not import a library to handle that?
>>
I like php.
$var=1; //not it is an int
$var.="Result: ".$var; //and now a string
echo $var; //'Result: 1'

$var="2"; //now it is a string
$var+=1;
echo $var; //3 //and now it is an int or a string, anyways, you get "3"

I wish other languages did this. If I expect an int I just intval() anything. Everything else is used as a string.
>>
>>59621831

That's automatic type conversion. That's different.
>>
>>59619646
Language features implicit type coercion instead.
>>
>>59619646
there's none
>>
>>59619646
It's only really useful for vector/matrix arithmetic.
You're much better off using macros/inline functions than abusing the same characters to mean multiple things.
You can't use nested <> operators in C++ without being misunderstood as stream operators.
>>
>>59623341

Or just add spaces, cretin.
>>
>>59621831
This isn't operator overloading you nerd
>>
>>59619646
>1 (one)
stopped reading right there
go outside you filthy autist
>>
>>59623444
>significant whitespace
AAAAAAAAAAAAAAAA
>>
>>59624775

>
 x + = 2
doesn't compile
hurf durf muh significant whitespace
>>
>>59624815
This used to work in old versions of C because += was treated as 2 tokens and not as a single operator.
>>
>>59619646
Because my language is SHITE
>>
My language has no operators!
>>
>>59619646
Because there are about 5 people in the world who know anything about REGEX editing, and you're not one of them.
>>
>>59619646
operators and keywords have a fixed meaning within the programming community. Its how we learn to communicate each others ideas at the high end level.
>>
If you give every programmer their own scripting langauge nobody is going to be able to communicate, it will be like the Tower of Babylon or the Fall of Rome.
>>
Of course, nothing is preventing you from scripting your own babylonian langauge using scripting from an incan monkey god if you wish.

I hear plenty of people speak esperonto.
>>
>>59625770
>scripting from an incan monkey god
>scripting using heiroglyphics from an incan monkey god
>scripting using heiroglyphics from an incan monkey god that visited you during a insomnia and caffiene induced dream vision
>scripting using heiroglyphics from an incan monkey god that visited you during a insomnia and caffiene induced dream vision whering you defeated the monkey king and used his staff of infinite variable length to level out the milky way
>>
>>59625804
I'm never playing "telephone" with you ever again.

Purple Monkey Dishwasher.
>>
>tfw swift codebase
>Operators like × ∈ etc
It's truly why tier.
>>
>>59625913
is swift the new fortran?
can it be used outside of theoretical excersizes?
>>
Implying you should use operator overloading

CAPTCHA> SELF centre
Thread posts: 39
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.