« Getters and setters | Main | Arrays and higher-order functions in the type system »
Wednesday
Aug192009

Mascara 1.2 - With interfaces

Mascara 1.2 has been released, and supports interfaces, an often requested feature.

They work as you would expect very much like interfaces in Java and C#. Basically they describe a set of methods that any class that implements the interface must provide implementations for.

Interfaces may contain function and getter/setter declarations, but not variables or nested types. (Hence ECMAScript interfaces does not allow constants as in Java). Declaration are just function signatures without a body.

Example:

interface Moveable {
  function moveTo(x: int, y:int) : void;
}

class DialogBox implements Moveable {
    function moveTo(x : int, y:int) : void {
// implementation
}
}

Interfaces can inherit from multiple other interfaces, and classes can implement multiple interfaces.

Syntax is defined in the documentation.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (2)

This tool looks so rad. I hope to actually try and use it soon.
Is there a larger development effort using Mascara (for some corp work) or is the community interest picking up steam?

August 19, 2009 | Unregistered Commenterenefekt

Any chance of visibility modifiers? Creating closures for this purpose is a mess, I would use Mascara if they just added: private var x so I could avoid the hacky-wacky way this is achieved using closures and self invoking functions..yuck!

September 1, 2009 | Unregistered Commenteranon
Comments for this entry have been disabled. Additional comments may not be added to this entry at this time.