Archive for January 2004

Why is there a fork() if there is no spoon()?

-Unknown, seen at the blackboard infront of the toilets at DAIMI.

It’s time again… it’s my birthday! :-)

Umm... birthday cakes... Today is my 22nd birthday, I’m a whole year older than last year, where did the time go? :-)

I’ve had a nice quiet day so far — people have congratulated me, and I’ve received a few presents: a really nice pair of jeans from my Mom and Dad and a DVD that looks really funny from my little brother, Kristoffer.

As usual in January, then I’m busy with exams… I’ll have my third and final exam tomorrow from 9-13. I’ve invited half of [Skejbygård][] to come and have cake and chocolate on Friday, and Saturday will be spend with the family, so this is all in all a very busy week! And that’s not all — to night Stéphanie and I will go and have dinner, something that I’ve been looking forward to for a long time!

That’s it for now — I’ll have more adventures to talk about later…

Done with the first exam!

I had my first exam in this semester today, I’ve passed DAIMI:dOvs — the compilation course — with the grade 13! The exam went much better than I had hoped, let me explain why…

The main part of DAIMI:dOvs is to write two major programs: a compiler in ML that will compile a dialect of Scheme called DAIMI-Scheme into bytecode; and a virtual machine written in C which will execute the bytecode. Using this compiler and VM we then have to BootStrap a compiler given to us by our lecturer Olivier Danvy written in DAIMI-Scheme.

As the project went along Lars Petersen ended up writing a majority of the compiler and Thomas Mølhave ended up writing and designing most of the VM, especially the rewritten (and much better) second version. I coded a bit here and a bit there, made some infrastructure such as a cool Makefile, began the report and so on… The result was that I didn’t really have any major code which I could say: this is my code — I’ve designed it and I know every little detail in it. Both Lars and Thomas could do that with the compiler and the VM, respectively.

At the exam I started talking about garbage collectors — a pretty easy subject with lots to talk about. But that question was just for warming up. The real questions would come afterwards — Danvy started with a question about how one could change the parameter passing semantics in DAIMI-Scheme from eager to lazy evaluation. And that was just soo lucky, for I had in fact been looking at just that: I had spend the last couple of days just before the deadline trying to implement this as an extra feature in our compiler — Danvy picked the one bit of code that was mine!

So I started talking about lazy evaluation, first I defined it and compared it against the normal eager evaluation we’re all familiar with from languages like Pascal, C, Scheme, ML, etc. Lazy evaluation can be simulated “by hand” in most functional languages, but it’s builtin in a language like Haskell. I wanted to have our compiler compile a program like

(define first (lambda (a b) a))
(first (quotient 4 2) (quotient 2 0))

into a program that behaves like this one

(define quotient (let ([original quotient])
                   (lambda (a b)
                     (original (a) (b)))))
(define first (lambda (a b) (a)))
(first (lambda () (quotient (lambda () 4) (lambda () 2)))
       (lambda () (quotient (lambda () 2) (lambda () 0))))

This program will, when compiled like any other program, run without the normal runtime error caused by the division by zero in the second argument because the evaluation of the argument has been delayed.

I fiddled with this for a couple of days, and managed to get 270 out of 300 tests working, including the example above. But it was never prefect, but it was certainly good enough so that I could talk about it to the exam :-)

After having talked about the lazy extension, we talked abit about our optimizations — it turned out that there is a subtle error in it because our inliner will inline strings in the code. The inlined strings will then be assigned different locations in the store, making the eqv? function say that they are different, when infact they should be the same:

(define x "foo")
(eqv? x x)

is turned into just

(eqv? "foo" "foo")

which suddenly returns #f, that is, false, when it should return true. I could understand the problem when the censor explained it to me, but I quickly blamed Lars for it… :-)

The next exam will be a written exam in DAIMI:dSprogSem the 13th. Wish me luck!

Happy New Year!

I would like to wish everybody a Happy New Year! Let’s hope the new year brings fortune and happiness to everybody.

Making caramelized potatoes I celebrated the New Years Eve here at [Skejbygård][] together with my friends. Jesper Klintø had invited a lot of friends from Sønderjylland and then we were Christina Strøhl and myself from my floor. We were a total of 18 people, and we had to cook dinner for them…

I was assigned to make the caramelized potatoes — something that I’ve never tried before. So I phoned my mom and she told me how the recipe was, and when I made them Jesper’s girlfriend Hanne helped me get them right — she know everything there is to know about cooking, so I was in good hands. Svend Sørensen also helped me, so it was actually quite fun to do the cooking.

The rest of the night was spend eating all the delicious food and then partying… Svend and I went for a tour around the other floors to see how they were doing: there was a party on the first, fourth, and sixth floor and we were immediately invited in to all of them :-)

I stayed at the sixth floor until the clock was just about 24, then I went down in to the basement to wish people a happy New Year. I went back up to the sixth floor afterwards to look at the fireworks, and to try to take pictures of it.

Fireworks! It turned out to be quite difficult to get a decent picture of the fireworks, but I did manage to take the picture you see to the left. The problem is that you have to time the shot pretty well, and then there’s the problem of getting enough light into the camera, for with the longer exposures the images become badly shaken…

Finally, around four in the morning, I went back to bed. Today has been a really quiet day here at [Skejbygård][]… but that’s just what one would expect after such a night :-)

Now with New Years Eve out of the way, I’m finally starting to get into gear about my exams… :-/ I’ve got three exams coming up in January, the first one will be on the 7th, it’s the oral exam in DAIMI:dOvs. Then there’s the written exams in DAIMI:dSprogSem and Complex Analysis coming up on the 13th and 22nd, respectively.

Well… we’ll see how it goes…