Theme: we borrow from other languages, but Perl is not those languages. Yet Perl programmers program Perl like C.
MJD does not like beeping in class.
Trip changed the slides for us. (Thanks, Trip!) Yet Trip has never seen the towers of Hanoi.
The lady behind me came up with the most unique solution I've ever
heard. Rotate the puzzle around the middle peg. You still haven't
broken any rules.
We started with an example program for solving the towers of Hanoi, which printed the solution within the program. This is bad, because you might later change the program to (print a different message|drive a graphical display|run a lego mindstorms Hanoi robot). So, the first presented solution is to pass a $move_disk callback function.
Should write for programmers: make sure they can use your function without having to look at or touch your code.
Strangely, at this point, I just saw an ant crawling around under the translucent part of my blueberry iBook. Sorry for the distraction.
MJD doesn't believe his directory walking code runs into problems with directories too deep, despite a heckler in the audience who "just wanted to prove [him] wrong one time in this conference."
I just learned you can
opendir my $dh, $dir;
I knew the syntax, but I didn't know about the my.
The ant finally made it out the vents and is crawling up my screen. Carrying food, no less. (I don't want to know.)
Anonymous functions are like unnamed literal constants in the middle of code. Interesting analogy, but I don't remember having too much trouble with anonymous functions, myself. I used plenty of callbacks in my recent neural networks project.
Demonstration of writing subroutines that take callbacks and parameters to pass to the callbacks.
ISO picked A4 for the standard paper size. This is a good idea because if you divide it into two parts each part is proportional to the original.
Suggests using caching for a callback passed to sort. Good idea, especially for some of the screwed up sort callbacks I've written.
Great quote: "It's really hard to talk and think at the same time." Actually, MJD makes it seem easy...
I took the opportunity to drag us into internals by asking about variables shared between two closures. That was fun. In fact, after someone else asked for an even more detailed explanation, I actually pulled up the perl source and started looking for this.
"Structured Programming with Goto statements" by Knuth. ?
Do not memoize functions with side effects. Especially fork.
You can tell Memoize.pm to use a hash tied to a dbm file if you'd
like to memoize between invocations. "The cache in the hash comes
A really generic iterator might have methods like
You might do this with an anonymous subroutine style, as in
Mark has a book on these techniques online. Eventually it will be published (once finished), but even then it will be available online for free. Thanks, Mark!
We were treated to a great rant about iterators in C++. Either you roll your own and have to write 15 functions where you could have done just one in Perl, or you use templates (like the Standard Template Library) where you have the 15 functions written for you, which means you are in effect using a macro preprocessor. I enjoyed the rant.
There was a good demonstration of how you can get better object encapsulation with anonymous subroutines instead of objects. You might have seen this before in one of the POD's that comes with perl. (Or maybe I dreamed that.) But then he want on to show how you can bless your anonymous subroutine reference and make a normal looking (syntax wise) object. Actually I stayed up late last night stripping out a piece of my Stratego program where I was doing this. It wasn't the right solution there, although it's definitely the right solution in plenty of other cases.
Inheritance with anonymous subroutines used as objects. Disadvantage: you have to do it yourself. Advantage: you get to do it yourself.
We had agreed with Mark to extend the talk an extra thirty minutes because he was told he'd have 3 hours but there were only 2:30 scheduled. However, the lights and power in the room abruptly cut off at 5:00 on the dot and the screen retracted. "That's a very strong hint," said Mark, and we adjourned.