Hi,

I looked a bit at the existing hardcoded traversal methods in a Pharo/Moose image. To detect it, I used a traversal. Perhaps this can also be useful for people that want to teach what a traversal is, or what an analysis is, so I wrote a blog post about it:
http://www.humane-assessment.com/blog/looking-for-hardcoded-traversal-methods

Cheers,
Doru





On Sat, Dec 14, 2013 at 3:44 PM, Mariano Martinez Peck <marianopeck@gmail.com> wrote:



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 deepCopying 
4) Use the same traversal of 2) to get an approximate memory consumption of the transitive closure of an object

But 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 new
   package: ‘ConfigurationOfDeepTraverser’;
   load.
(Smalltalk globals at: #ConfigurationOfDeepTraverser) loadDevelopment.


Just to give you an idea, here are some representative examples:

Number
    deep: #subclasses 
    do: [:each | Transcript show: each; cr].

Number deepCollect: #subclasses.

Number
    deep: #subclasses 
    collect: #name.

Number 
    deep: #subclasses 
    do: [: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



--

"Every thing has its own flow"



--
Mariano
http://marianopeck.wordpress.com



--
www.tudorgirba.com

"Every thing has its own flow"