JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
85 stars 3 forks source link

How strict should we be about pure functions #110

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 5 years ago

Issue, or potential issue

Pure functions in Mamba are almost pure, but not quite. Namely, while we disallow reading from global mutable variables, we do still allow writing to mutable variables outside the function, which is still a side-effect.

The question is, do we want to disallow this? While this would make functions pure by definition, it would perhaps also decrease their usability. My main concern is that while this feature would be nice, it is perhaps too cumbersome to use resulting in developers not using the feature at all.

I often see discussions about functional programming languages, and how they are safe, but that they are also often too restrictive, resulting in them not being used at all. I think this discussion is somewhat similar to such discussions. Do we wish to be pragmatic, and make functions "almost pure", or do we want to make them truly pure?

JSAbrahams commented 2 years ago

Okay it should not have any side-effects, so it shouldn't write to anything.