Inline Expansion

In addition to macro expansion Apparat has now inline expansion as well. It works nearly the same way as macro expansion but without most of its limitations. To define a class for inline usage it must extend apparat.inline.Inlined and all its methods must be static. However the cool thing is that you can also return values in contrast to macro expansion. You can also pass normal parameters. For instance FastMath.sin(FastMath.sqrt(2.0)) is valid code using inline expansion. It is enabled by default in TDSI.

3 Comments

  1. Posted May 24, 2010 at 8:37 pm | Permalink

    Is there a reason to still use macro expansion or is inline expansion better in every way?

  2. Posted May 24, 2010 at 9:01 pm | Permalink

    It is a different feature. But I would always go with inline expansion.

  3. Posted May 25, 2010 at 12:34 pm | Permalink

    Well, actually it depends on what you want to do. Macro expansion can be very nice for bitwise operations. E.g.

    BitMacro can define swap(x: int, y: int): void { x ^= y; y ^= x; x ^= y; } which would not be possible using inline expansion :)

3 Trackbacks

  1. By joa (Joa Ebert) on May 24, 2010 at 6:14 pm

    inline expansion for apparat now available http://bit.ly/dBKkpK

  2. By elsassph (Philippe Elsass) on May 24, 2010 at 6:27 pm

    Smart stuff – is there a ref of all apparat feats? RT @joa: inline expansion for apparat now available http://bit.ly/dBKkpK

  3. [...] This post was mentioned on Twitter by Joa Ebert, Philippe Elsass and tony murphy, MojoGeeks. MojoGeeks said: Inline Expansion: In addition to macro expansion Apparat has now inline expansion as well. It works nearly the sam… http://bit.ly/aucYVx [...]