static inline var precalculation?

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

static inline var precalculation?

Robin Palotai
Hi!

When declaring a "constant" via public static inline var FLAG = 1 <<
2, this cannot be passed as a default parameter value right now,
because "Parameter default value should be constant". Should the
compiler preprocess such values somehow? Is there a way to force this?

Does this also mean that when I use operations on constants in the
code (I mean 5*300-4), these operations are left unprocessed by the
compiler and actually calculated again and again in the program?

My target is flash9.

Thank you very much!
Robin

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

Re: static inline var precalculation?

Nicolas Cannasse
Robin Palotai a écrit :

> Hi!
>
> When declaring a "constant" via public static inline var FLAG = 1 <<
> 2, this cannot be passed as a default parameter value right now,
> because "Parameter default value should be constant". Should the
> compiler preprocess such values somehow? Is there a way to force this?
>
> Does this also mean that when I use operations on constants in the
> code (I mean 5*300-4), these operations are left unprocessed by the
> compiler and actually calculated again and again in the program?

Yes, right now constant calculus are not optimized.
This is planned for 2.02 or 2.03. And at this time it will work with
default parameters value as well.

Actually, I'm planning to perform a lot of different optimizations
related to inlining.

For instance when calling (if inlined) :

        Lambda.map(array,function(x) return x.name)

This will produce the following code :

        var l = new List();
        for( x in array )
                l.add(x.name);
        l;

And will then "inline" the closure as well.

Nicolas

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

Re: static inline var precalculation?

Robin Palotai
Great, thank you very much!
Robin

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