[osflash] New Language RFC

Nicolas Cannasse ncannasse at motion-twin.com
Thu Nov 3 23:41:32 EST 2005


> ok i see.
>
> Another idea which comes to my mind:
> What about beeing able to specify multiple types for a parameter?

As you shown, multiple types require some kind of discriminating matching.
I would prefer extend the enum's so they can take parameters :

enum AnyNumber {
    int( Int );
    float( Float );
}

function plusOne( x : AnyNumber )  : AnyNumber {
    switch x {
    int(i) => int(i + 1);
    float(f) => float(f + 1);
    }
}

This is not "true" pattern matching yet since there is no recursivity but it 
might be already a nice this way to acheive some dynamic typing and 
polymorphism in a safe-manner.

Nicolas




More information about the osflash mailing list