On Wed, Dec 11, 2013 at 12:21 PM, Tudor Girba <tudor@tudorgirba.com> wrote:
Hi,I put together a little implementation for traversals. It is inspired by an original implementation from Mariano.Wow... my memory is sooo bad I don't remember ;)Using DeepTraverser, you can traverse arbitrary graphs by describing the traversal and by specifying the actions you want to perform on the nodes and relations.Once (or even more times) we thought with Martin 2 things:1) Reify the traversal in Fuel so that we could plug a different one.2) Use Fuel only for traversing and allowing user a hook to plug the what to do with each node.3) Use the same traversal of 2) for deepCopying4) Use the same traversal of 2) to get an approximate memory consumption of the transitive closure of an objectBut as always happened we run out of time.Anyway...I think this is a nice area to explore. There are many uses for a nice traverser.Also, did you see we wrote a Rossal extension to print the fuel traversal?The code is available in the Moose image as part of the MooseAlgos subproject, but can also be loaded separately in a Pharo image via:Gofer newpackage: ‘ConfigurationOfDeepTraverser’;load.(Smalltalk globals at: #ConfigurationOfDeepTraverser) loadDevelopment.Just to give you an idea, here are some representative examples:Numberdeep: #subclassesdo: [:each | Transcript show: each; cr].Number deepCollect: #subclasses.Numberdeep: #subclassescollect: #name.Numberdeep: #subclassesdo: [:each | Transcript show: each; cr]relationDo: [ :from :to | Transcript show: from; show: ' <-- '; show: to; cr ].More details about the usages and a little description of the implementation can be found here:Cheers,Doru--
Mariano
http://marianopeck.wordpress.com