Doubt with stop conduction

32 views
Skip to first unread message

imaiolo

unread,
Mar 19, 2014, 2:17:52 PM3/19/14
to boa-...@googlegroups.com
# Counting the number of active Java projects with SVN
p
: Project = input;
counts
: output sum of int;
nrOfProject
: output sum of int;


nrOfProject 
<< 1;
visit
(p, visitor {
 before n
: Project -> 
    ifall 
(i: int; !match(`^java$`, lowercase(n.programming_languages[i]))) 
        stop
;
 before node
: CodeRepository ->
 
if (node.kind == RepositoryKind.SVN)
 exists 
(j: int; yearof(node.revisions[j].commit_date) == 2011)
 counts 
<< 1;
});

I have a doubt with stop condiction. For example in the exercise above we would count: 
"#Counting the number of active Java projects with SVN", but if the ifall condiction is verified for all the value of n.programming_languages[i] and the stop condiction is evaluated, the next vist clausle it is not executed and the program switch to a next project, is it right?.

Robert Dyer

unread,
Mar 19, 2014, 3:47:12 PM3/19/14
to boa-...@googlegroups.com
Hi Ilario,

You are absolutely correct here.  If the condition in the ifall statement holds for all values of 'i', then the stop statement will execute.  If that stop statement executes, the child nodes (the entire subtree rooted at the Project node) will not be visited.  Effectively, we will skip processing this Project.

But this is the intended behavior.  We only want to keep projects where one of the programming languages is Java.  So if none of them are Java, we can stop processing this Project.

If however one is Java, then the ifall found a value of 'i' where the condition does not hold (because the match returns true, and is negated, giving the condition a value of false) and thus it will not execute the stop statement and continue visiting the subtree.

One final note is your statement 'the program switch to a next project.'  Note that in Boa, all projects are analyzed in parallel.  So it won't 'switch to a next project' but simply this particular thread will stop processing this particular project.  All the other projects will continue to run this analysis, in parallel.

I hope that answers your questions!

Best Wishes,
- Robert
Reply all
Reply to author
Forward
0 new messages