Main

June 10, 2009

What I'm working on these days

I'm back. I won't bore you with my personal travails, but will instead skip right to what I've been working on lately. Most recently, I've been documenting the new Text Layout Framework, which provides an easy way to take advantage of the immense power of the flash.text.engine package available in Flash Player 10.

Going forward, I'll be splitting my time between the Text Layout Framework and the creation of an updated version of the ActionScript 3.0 Language Specification.

Continue reading "What I'm working on these days" »

August 1, 2008

moockblog String Concatenation Error Explained

Colin Moock blogged today about an interesting little ActionScript 3.0 string concatentation gotcha. I'll try to summarize what he said, but I encourage you to read his post and come back for my explanation.

The issue is that the following code:

trace("Hello" + + " world");

generates the following error message:

1067: Implicit coercion of a value of type String to an unrelated type Number.

Colin calls the error message misleading, and I can see why it seems so, but I'm going to argue that the message is accurate, even if it is obscure.

Continue reading "moockblog String Concatenation Error Explained" »

July 16, 2008

Colin Moock's Charges Against ActionScript 3.0

Yesterday, Colin Moock published an interesting article about nine problems he sees with ActionScript 3.0 and Flash Player 9. Most of the charges he makes are specific to the Flash CS3 authoring environment, and the general theme is that ActionScript 3.0 and its implementation in Flash CS3 makes the development process more difficult than it should be for users without significant programming backgrounds.

Continue reading "Colin Moock's Charges Against ActionScript 3.0" »

March 7, 2008

Proposed ... (splat) operator in ECMAScript 4th Edition allows easy pass-through of rest arguments to super constructor.

Recently, Brendan Eich added a new trac ticket that proposes a new operator, ... (informally called "splat"), for ECMAScript 4th edition. The fate of this ticket is currently unknown, but I really like this proposal because it solves a thorny issue I've had when trying to pass ...rest arguments to a super constructor in ActionScript 3.0. I'll get back to that problem in a minute, but first I want to draw a clear distinction between the proposed ... (splat) operator and the ... (rest) parameter that many of you have probably used in ActionScript 3.0.

Continue reading "Proposed ... (splat) operator in ECMAScript 4th Edition allows easy pass-through of rest arguments to super constructor. " »

February 28, 2008

Type Parameters in ECMAScript 4th Edition

The ECMAScript 4th Edition draft specification includes something called type parameters, also known as parameterized types or generics. This feature is useful for adding type checking to collection classes. For example, let's say you have a List class that you have customized to your liking.

Continue reading "Type Parameters in ECMAScript 4th Edition" »

February 13, 2008

Vectors in ECMAScript 4

A new built-in class named Vector is proposed for ECMAScript edition 4. This class is similar to the Array class, but is designed for better performance, efficiency and error checking. Some interesting aspects of the Vector class:

  • vectors are dense;
  • vectors do bounds checking;
  • vectors can be fixed length;
  • vectors have type parameters;
  • vectors have the same methods as arrays.

Continue reading "Vectors in ECMAScript 4" »

February 7, 2008

Logical Assignment Operators

Thought I'd switch gears this week and talk about Logical Assignment Operators (||=, &&=), a feature that is proposed for ECMAScript 4th edition, but is already implemented in ActionScript 3.0. To understand the rationale behind the Logical Assignment Operators, you need to understand how the logical operators in ECMAScript and ActionScript work. Most people think of these operators in purely boolean terms. In other words, if you have two boolean variables, conditionA and conditionB, you can use the logical operators to calculate logical results. For example, if one condition is true and the other is false, the logical AND operator returns a value of false because both conditions have to be true in order for logical AND to return true.

Continue reading "Logical Assignment Operators" »

February 1, 2008

Proper Tail Calls and State Machines

It turns out that Proper Tail Calls (PTC) are handy if you want to create a simple "state machine" or "finite state machine" (See my previous post if you don't know what PTC is). A state machine is a way to create a model for the way an object behaves. For example, let's create a state machine model for a United States traffic light. First I'll use a design pattern to create one, then I'll show you a completely different approach using PTC. Here are the components of the model:

  • Finite number of states. There are three states in our example: red, yellow, and green.
  • Input. This is an event-driven model, so the input is an event that signifies a light change.
  • Finite number of transitions. There are three transitions in our example: red to green, green to yellow, and yellow to red.

Continue reading "Proper Tail Calls and State Machines" »

January 30, 2008

Proper Tail Calls and Recursion

Today I'm going to talk about the proposed Proper Tail Calls (PTC) feature and recursion. I'm going to show you how PTC can significantly reduce stack usage for functions with recursive calls in tail position. If you recall, I mentioned in my previous post that Proper Tail Calls is also called Proper Tail Recursion. This is because PTC has a significant effect on certain types of recursive functions. In case you're unfamiliar with recursion, a recursive function is a function that calls itself. For example, we could use a recursive function to calculate the factorial of a number, which means multiplying a number by every integer between that number and zero, as in 3! = 3 x 2 x 1 = 6.

Continue reading "Proper Tail Calls and Recursion" »

January 28, 2008

Proper Tail Calls, a definition

One of the things I get to do here at Adobe is help out with the drafting of the ECMAScript Edition 4 (ES4) language specification. Lately, there has been a flurry of discussion on the ES4-discuss list about one of the proposed new features, Proper Tail Calls (a.k.a. Proper Tail Recursion, but I'm going to call it PTC from now on). I thought this might give me a good opportunity to provide some background information about this feature and what it might mean for ActionScript developers in the future.

In case you don't know, ECMAScript is the language standard upon which JavaScript, JScript, ActionScript and many other languages are based. The current version of ECMAScript is the third edition, but a lot of work is going on for the fourth edition. So what I'm discussing here is not currently in ActionScript, but may one day be if PTC makes it into the fourth edition specification.

Continue reading "Proper Tail Calls, a definition" »