Results from a meeting

Last Tuesday I went to Delft for a meeting with Martin after a long period of only communicating through email/IRC. Although these form of text-communication work fine a real-life meeting will make it easier to discuss things.

One of the subjects of the discussion was my paper for the STC. I already gave my presentation for this course, but finishing the paper was not an easy task for me. As you might have noticed it is quite a challenge for me to write a text in understandable English. When the text must also contain some formal definitions and clear examples the speed of my writings quickly degenerates. However, I still managed to put together a reasonable result. After we discussed which parts needed some modifications I improved the paper in the past couple of days. The result can be found at the new talks-and-paper-page on php-sat.org. Please feel free to provide constructive feedback.
When you followed the link you might have also seen the new page for the PHP-Tools package. This package is now also build within the build-farm, thank you Martin, and available for download. If you have a cool idea for a tool please let me know via the bug-tracker.
Other topics that we discussed will help to improve the path-strategies for file-inclusion, improving the SDF-definition for HereDoc, develop more concise error-reporting and generating the priorities for precedence from the YACC-definition. I have worked a little on all of these issues in the last two weeks, but now I have better ideas to handle the problems I ran into.

A last topic of discussion was an idea I had for an algorithm to use in my thesis. This algorithm uses a set of allowed rewrite rules to ``guess'' the rule a student wanted to apply. I already wrote an example-scenario for my proposal, which is coming along great by the way, so after I reread this I will discuss it in a blog. I'll keep you posted.

Including only once

This week I finally got around to the implementation of a strategy that combines constant-prorogation and some sort of type-state. It was a bit tricky to get it completely right, resulting in some very weird behavior during testing. Fortunately, the problem has been solved and the result is pretty good!

So what problem does this strategy solve? In order to explain this we will first take a quick look at how constant propagation is being handled within PHP-Front (and other Stratego-libraries).

When a value of a variable is known, for example when it is defined in an expression like $foo = 5, PHP-Front will add a dynamic rule rewriting the variable to the known value. This dynamic rule can later be used to retrieve the value, for example in the expression $bar = $foo+1. This last expression will then be rewritten to $bar = 5+1 which can be completely calculated again.

Using dynamic rules for linear code is easy, but when code branches it becomes a little bit more complicated. Take this example code:
  $foo = 'say';
  if($val){
     $bar = 'hello';
  } else {
     $bar = 'world';
  }

The value of $bar can not be statically determined, but we want to keep the knowledge about the variable $foo. A valid way to do this is to take the intersection of the two sets of dynamic rules, the normal one and the one after evaluating the if-branch. This will keep all information about variables that are not used, or given the same value, within the branches of the if.
If you want to know more about dynamic rules and constant propagation I suggest you take a look at this paper.

Besides the information about the constant propagation we need to take a look at the inclusion mechanism of PHP. You might be aware of the fact that PHP offers both an include as well as an include_once construct. The first one will always include a file, the latter one will only include a file when it wasn't included before.

Dealing with files that are always included in combination with constant propagation is rather easy. We just retrieve/parse/evaluate the file during the constant propagation. Dealing with files that are only included once is also easy with linear code, but things get tricky when branching is involved. Take this piece of code for example:
  if($val){
    include_once 'foo.php';
  } else {
    //other things
  }
   //some code
    include_once 'foo.php';

Within the if-branch the file foo.php might be included and introduce some dynamic-rules. The code for the if will handle this probably so that is not a problem.

But what must we do when we arrive at the other include_once-construct for the same file? Well, there are three different scenario's that can occur:
  1. File has not been included
  2. File might have been included
  3. File is definitely included
The first and last one are easy, just include the file or not, the second one is more complicated with respect to dynamic rules. We will again have to take the intersection of the current set of dynamic rules and the set of dynamic rules after inclusion of the file. This will make sure that we only keep the rules that will be the same in both cases.
Notice that we will have to keep track of the inclusion-state of every file. This can (and is) implemented as a state for a file, again with dynamic rules.

Implementing both of these solutions with dynamic rules separately is not that difficult, there are enough sources to figure things out. However, combining these approaches is completely trivial because you will have to deal with dynamic rule-sets and all sorts of merge-strategies. Fortunately for you this is all done behind the scenes. Please enjoy the better constant propagation as of revision 332.

Thesis subject

Working on PHP-Sat this weekend got me a response on Sunday-evening in #stratego. I was told that it was nice to see some more progress on PHP-Sat again. It's very nice to receive such feedback!

What this comment also expressed is that the past month the actual progress on PHP-Sat was not really visible. I have mostly been working on the website and on the GrammarEngineeringTools. Two things that will improve PHP-Sat, but not directly.

But I have to admit, there was another activity that quickly filled up my time:
My thesis-proposal.

I have mentioned before that the subject of my thesis is interesting (of course!), but didn't not explain what it is about. So here is the short version of the goal:
By combining techniques from the field of term-rewriting, strategies and generic programming we aim at supplying a generic framework that supports the generation of rule-feedback with minimal effort.

After reading this, the first question would probably be 'what is rule-feedback?'
Well, imagine a tool that allows you to solve a mathematical exercise such as:
1/2 + 2*(4/5)
by rewriting the expression in little steps. So the first rewrite would evaluate the multiplication which result in:
1/2+8/5.
The second rewrite will perform the addition and will lead to the answer of:
21/10.
(Notice that the rules I applied here are actually a set of combined rules, adding two fractions with different denominator takes more then one step.)

When the application of a rule is incorrect, for example the answer 9/5 for the expression above, feedback will need to be provided. Useful feedback would help a student to understand the mistake that has been made. In this case it could be something like:
You have added two fractions without considering the denominators. Remember that fractions can only be added when the denominators are equal!

I have done quite a bit of research on the feedback that is currently given in educational tools. The conclusion is that it can definitely be improved and certainly needs to be made easier to define. By supplying a generic framework the task of implementing a complete tool is simplified into the specification of the domain.

How this specification can be done, and more details on how the generation of feedback will work, will be explained in some later blogs. I just wanted to let you know what I was doing all day :)

Visiting Dublin

My girlfriend and I went to Dublin this weekend and we had a great time. We flew with Aer Lingus and stayed at the Jacobs inn. This hostel really relaxed and I can certainly recommend it to anyone who just wants to sleep low budget. We basically did some sightseeing and walked around town. On Saturday we went to Radio City Dublin to see the Heideroosjes, the coolest punk-band I know.

Radio City is a cozy basement with a bar, a stage and room for about 200 people. It looks professional, but they could improve the information flow about who is going to play when. When we asked which bands played that evening it took about 10 minutes and 4 people to tell us that they didn't have a clue. It all worked out fine though. Seeing the Heideroosjes in a place with only 20 people, half of them Dutch, was a bit weird, but they definitely rocked! We plan to see them again in the Melkweg on the 16th of March, hopefully with a bigger crowd :)

The weekend in Dublin has given me some time to think about the things I want to do this year. I have made up a little list of the most important things that I want to pursuit this year, a kind of (very late) New Year's Resolutions:
These goals are not very surprising, but they require some shift in my priorities. Let's see if I can be part of the 46% that keeps such resolutions after 6 month. I personally think that the last one will be the hardest one to keep :)

PHP-Sat.org finished

It took me a ((very) long) time, but I finally finished all the texts for PHP-Sat.org. It is always a challenge to think of the right subjects and placement of texts for a website, but I believe that everything is in the right place now.

The website contains all the basic things a project need: general information, source repository, mailing-lists and bug-tracker. The current information is quit basic, but it will grow over time.

But the website also contains some extensive documentation on the following topics:This is also the reason it took some time to finish the site, but I think that it was useful. It gave me a a change to think about several aspects of the project.

Please let me know if you find any (spelling)-mistakes in the texts, still practicing my English over here.