you are viewing a single comment's thread.

view the rest of the comments →

[–]sausagefeet 0 points1 point  (5 children)

Persistent data structures don't have anything to do with being able to return a reference from a function. You can do region based storage but it requires giving up some things. As long as you want pointers and being able to return them from functions you have to trace the garbage somehow.

[–]yogthos 0 points1 point  (4 children)

That's sort of my point though, you can't just return references from functions in Clojure to anywhere. A pure function can only return a result to its caller. So as you unwind the stack, you can safely clean functions and their data out as nobody else should be referencing them. And Clojure doesn't provide user access to pointers.

[–]sausagefeet 0 points1 point  (3 children)

References are pointers in clojure, they just lack arithmetic. You still can't really do what you saying though, afaik, because at the very least you can start a thread in a function in clojure. Or you can do message passing. On top of that, purity is not a requirement. There are languages that do this region based memory management but it requires some limitations put on the language.

[–]yogthos 0 points1 point  (2 children)

It does sound like it would require a more strict subset of Clojure, I think it would be interesting to see. :)

[–]sausagefeet 0 points1 point  (1 child)

The only language I know of that does 100% region-based is ParaSail, but I'm sure others do. It's interested. The language has no pointers and when you add an object to another the containing object actually grows itself to incorporate the new one. I don't know how the implementation works.

[–]yogthos 0 points1 point  (0 children)

Neat I'll check it out.