April 2008

Partial Application in Actionscript 3.0

UNFINISHED, but I’ll just post it for now, cause who knows when I’ll get around to this again!

One thing I don’t like doing is labeling things as “advanced”. I remember back in the day when I was just-barely-a-teenager and I was figuring out C. I read through a book or two and got to the topic of “linked lists”. I remember back then thinking that sort of stuff was considered, in my and the book’s opinion, “advanced”–and that I thought was pretty hardcore knowing how to do it. I knew that knowing it didn’t necessarily make me the best programmer in the world… but I had to have definitely been somewhere in the top 10. Maybe even the top 5.

Today, I’m a tiny bit wiser than I was back then.

For functional programmers, currying and/or partial application may be well understood early in the learning process. Actionscript 3.0, an ECMAScript language, is actually extremely versitile, even when it comes to those crazy Functional Programming topics. Still, AS3’s “classical OOP” appearance can make some of those functional programming paradigms a rough fit.

So I won’t say that this stuff is “advanced”, but if you’re not intamitely familiar with AS3, and if you’re not already comfortable with closures and partial application from other languages, then this is probably going to hurt, at least a little bit.

For the record, I’m a beginner at this sort of stuff. Keep your eyes peeled for mistakes!

Continue Reading »

Actionscript 3.0
Tutorials

Comments (7)

Permalink

Closures in Actionscript 3.0

For right now, this is a direct copy of a forum post (with a hard character limit on posts). I might come back and spiff it up some, but then again maybe not. I DO WHAT I WANT!

It’s on closures, and it’s stuff you need to know before looking at the stuff on partial application. You don’t necessarily need to know the stuff I address here specifically, just what a closure is and stuff.

First, before I even start to get into this, I want to say that Actionscript is an ECMAScript derivative. Javascript also falls into this category, so you can often find tutorials, examples, etc which translate easily from one language to another. A VERY good explanation of Closures and a few of their uses can be found here, but is biased towards Javascript, and isn’t the most accessible thing out there ;)

Second, the uses of a “closure” are not really a clear-cut. If someone asked you “what can a class be used for?”, there would be no single definite way to answer the question. Closures, in fact, can almost be thought of as another way of representing a class (but don’t think of them that way!), but offer other practical uses as well. In this example, we’ll discuss what a closure is and then use one to help solve the common problem of “passing arguments to event handlers”, as well as pick up a nifty trick or two.

Continue Reading »

Actionscript 3.0
Tutorials

Comments (1)

Permalink