interface info at runtime

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

interface info at runtime

Hudson Ansley
Hi haXers,
I noticed that interfaces in Flash are compiled into the code whether
they are used at runtime or not (e.g., object is interface). Is this
also the case with haXe? IOW, if I don't explicitly use "Runtime Type
Information" are interfaces compiled into byte code and stored in the
resulting swf? (assuming a flash target, of course) I'm asking because
my current project needs to be as small in filesize as possible, and
although interfaces are not huge in flash swf compiles, they can add
up... and since haXe uses type inference, seems like it might be able
to avoid keeping this info in the runtime.

Regards,
Hudson

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: interface info at runtime

Nicolas Cannasse
Hudson Ansley a écrit :

> Hi haXers,
> I noticed that interfaces in Flash are compiled into the code whether
> they are used at runtime or not (e.g., object is interface). Is this
> also the case with haXe? IOW, if I don't explicitly use "Runtime Type
> Information" are interfaces compiled into byte code and stored in the
> resulting swf? (assuming a flash target, of course) I'm asking because
> my current project needs to be as small in filesize as possible, and
> although interfaces are not huge in flash swf compiles, they can add
> up... and since haXe uses type inference, seems like it might be able
> to avoid keeping this info in the runtime.

Yes, this is also the case in haXe.
However, you can define typedefs and anonymous types in haXe :

typedef MyAPI = {
        var x : Int;
        function foo() : String;
}

They will work structurally (so you don't need to implement MyAPI), and
will only be used at compile-time.

The drawback is that on Flash9 all fields accesses on such types are
dynamic so you're losing a bit of performances compared to interfaces.

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: interface info at runtime

Hudson Ansley
Interesting, thanks very much for the information. I find I learn more
from this list about Actionscript than any Actionscript list I've
belonged to :-)
Regards,
Hudson

On Mon, Nov 17, 2008 at 3:24 PM, Nicolas Cannasse
<[hidden email]> wrote:

> Hudson Ansley a écrit :
>>
>> Hi haXers,
>> I noticed that interfaces in Flash are compiled into the code whether
>> they are used at runtime or not (e.g., object is interface). Is this
>> also the case with haXe? IOW, if I don't explicitly use "Runtime Type
>> Information" are interfaces compiled into byte code and stored in the
>> resulting swf? (assuming a flash target, of course) I'm asking because
>> my current project needs to be as small in filesize as possible, and
>> although interfaces are not huge in flash swf compiles, they can add
>> up... and since haXe uses type inference, seems like it might be able
>> to avoid keeping this info in the runtime.
>
> Yes, this is also the case in haXe.
> However, you can define typedefs and anonymous types in haXe :
>
> typedef MyAPI = {
>        var x : Int;
>        function foo() : String;
> }
>
> They will work structurally (so you don't need to implement MyAPI), and will
> only be used at compile-time.
>
> The drawback is that on Flash9 all fields accesses on such types are dynamic
> so you're losing a bit of performances compared to interfaces.
>
> Nicolas
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org