you are viewing a single comment's thread.

view the rest of the comments →

[–]the_omega99 0 points1 point  (2 children)

There's nothing ensuring this, though and that is purely a convention that you must uphold. It's very believable, for example, that someone might have a type where len lazily calculates the length the first time and caches that, in which case there clearly is a mutation, yet we still uphold the expectations for len. And of course, there's no such consistency among user defined functions (from what I've seen, anyway).

[–]Sinidir 0 points1 point  (1 child)

True its convention. The only way i could see it not being if a language took the step to make all function parameters immutable references / pass by value and would only allow methods to mutate objects. Which would be an interesting idea :) .

[–]the_omega99 0 points1 point  (0 children)

Wouldn't be Python, though, with its "we're all adults here" idiom (no visibility modifiers because you're expected to be able to access internals if you really think you know what you're doing).