Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 5110 days ago | link | parent

I'll note that if environments didn't have an `outer` attribute, and I made the `body` attribute read-only[1], then you could still get information hiding (with closures), but at the cost of (slightly) decreased malleability[2].

I could still allow for mutating the arguments list and environment, since I don't think that would leak hidden information (if you know of a way, I'd like to hear it!). Of course, if I went that route, then I should give a way for Arc code to "freeze" an attribute, making it read-only.

Side note: if every function had an `arguments` attribute, then the `sig` table in Arc would be redundant, and could be removed.

---

* [1]: Why would the `body` attribute need to be read-only? Consider this simple example, demonstrating information hiding:

  (let a 0
    (def foo ()
      (if (< a 3)
        (++ a))))
        
  (foo) -> 1
  (foo) -> 2
  (foo) -> 3
  (foo) -> nil
If I allowed for mutating the function's body, then you could remove the `if` check. In a less contrived example, you could mutate the function so it gives you direct access to the information hidden in the closure.

* [2]: I say it's only slightly decreased, because it's still possible to "mutate" a function by wrapping it in another function. This is what `extend` does.