3 ms·
Alan Kay wrote a paper about a very elegant metaphor to solve this, it's called "Worlds": http://www.vpri.org/pdf/rn2008001_worlds.pdf You create a "world
by andreyf 18y ago
Alan Kay wrote a paper about a very elegant metaphor to solve this, it's called "Worlds":
http://www.vpri.org/pdf/rn2008001_worlds.pdf
You create a "world" for your Classifier gem, which (in a trivial implementation) makes local copies of any global objects when they're modified instead of actually changing them. ActiveSupport runs in yet another "world", and knows nothing about the "local" changes to the global variables Classifier made.
- jrockway 18y agoI don't think this is quite what Worlds are. Worlds would not allow you to have a data structure that is used by both Rails and Classifier. FWIW, ContextL is closer to the solution: http://common-lisp.net/project/closer/contextl.html http://common-lisp.net/project/closer/contextl.html But it's still better to just add a standard "array that does 'sum'" to the language, or for Rails and Classifier to cooperate.
- andreyf 18y agoWorlds would not allow you to have a data structure that is used by both Rails and Classifier. I might be misunderstanding it... but why not?
- arebop 18y agoIt seems to me that worlds permit sharing immutable data structures, and that Warth & Kay's operations on worlds do not permit sharing mutations done in parallel worlds. The Worlds paper you cited [http://www.vpri.org/pdf/rn2008001_worlds.pdf http://www.vpri.org/pdf/rn2008001_worlds.pdf] cites the COP overview paper [http://p-cos.net/documents/contextl-overview.pdf http://p-cos.net/documents/contextl-overview.pdf] mentioned near the top of the link jrockway gave. Warth & Kay say "Similarly, in order to support context-oriented programming (COP) [8], we may want to add a third key to our lookup table that identifies a context." So that gives me some confidence in my interpretation.
- stcredzero 18y agoCooperation is dandy if n = 2, but for n > 2, this can get cumbersome. Unfortunately method names like 'sum' are very attractive. A language/library designer shouldn't have to think of "all of the short or otherwise possibly overloaded nouns and verbs people might like to use, ever." Being able to say you are going to do a 'sum' which means X in this particular context is very powerful. This notion should also be unified with version control. (As in OS X, where a process only sees the versions of libraries that it is supposed to run against.)
- jrockway 18y agoA language/library designer shouldn't have to think of "all of the short or otherwise possibly overloaded nouns and verbs people might like to use, ever." Being able to say you are going to do a 'sum' which means X in this particular context is very powerful. In this specific case, what's needed is more abstraction. Consider the approach Haskell takes: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Monoid.html http://www.haskell.org/ghc/docs/latest/html/libraries/base/D...
- _pius 18y agoI believe Cucumber uses this approach: http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-wo...