News for hackers. Stuff that matters.
Re:On Scaling Mental Models by mason55 on Sunday March 22, 2020 @11:06AM (#22655408)
In a statically-typed language you’d just get a compile error. The compiler knows the types of the values in the map and whether or not the (+) operation is valid for them. You’d likely need a little more code than what’s in the GP post, something restricting the values in your map to types that implement “addable” or whatever the terminology is for your language.

In a dynamically-typed language you’d get some kind of runtime error.

Just think of (+) like any other function and what would happen in your language if you call a function with types that the function doesn’t support.

Re:On Scaling Mental Models by AzzieElbab on Sunday March 22, 2020 @03:00PM (#22657547)
Well, in Scala with default predef it would depend on the order or the arguments. If first one is a string it would just append string representation of the second one. One could use a random generator to guess what would happen in JavaScript. I do not know what Python does in these cases
Re:On Scaling Mental Models by AzzieElbab on Sunday March 22, 2020 @05:51PM (#22659038)
Sorry for being cryptic, the point was that I prefer appenders being explicitly documented in types or method signatures instead of some built-in magic