From: Todd S. <to...@su...> - 2012-09-09 10:27:07
|
As always, thanks for the feedback and discussion. Special thanks to Tim and Albori for testing! I just pushed more changes to the MOOCode API. For the most part, this consisted of opening up built-ins like `verbs()', `properties()', etc. to accept an anonymous object as the first argument. Internally, a lot has changed, and I'm still testing things like db dump/load **so make sure you keep a backup of your database**. That said, I'm starting to rework my apps to use this new capability. A good example, from my perspective, is request handling in Dialog. The old way, requests were dispatched to verbs on a user-defined controller object for handling. Verbs were handed `request' and `response' frobs, which represented the HTTP-request-specific and transient aspects of the workflow. The controller was static. Because a controller was static, it wasn't easy/convenient to implement request-specific state. It also wasn't easy to mix in context-specific functionality in a duck-typed sort of way -- verbs that act one way in a testing context vs. a development or production context. The new way, a new anonymous child of the controller is created for each request. Context-specific helpers are mixed in as well: in production, `request()' and `response()' verbs return the corresponding request and response objects; in a test, they return mocks, for example. The Dialog framework is doing something like the following for each request: temp = create({<controller>, <request/response>, <session>}, 1); temp:(<action>)(<params>); Other than testing, the big remaining to do is garbage collecting cyclic references among anonymous objects. Replies to other comments in the thread: 1) WAIFs -- I used them before, but they didn't solve my problem this time around. However, there's nothing that I am aware of that precludes using both WAIFs and anonymous objects. 2) $runnable -- no way! I'll add real lambdas soon enough. Todd |