Expression Editor Syntax

Hi everybody, welcome to the fourth edition of the Fusion3 development blog. As a continuation of last weeks talk about the new type system I thought it was appropriate to talk a little about our change to the expression editor syntax.

A look back

In Fusion2.5 and older we used the C-style function syntax:
SomeProperty(“MyObject”, someParameter, someOtherParameter)
Like X(“MyObject”), Left$(“SomeString”,5)

While you might immediately recognize the above examples and know what they do, there are other examples where that might not be immediately clear.
For example: something$(“SomethingElse”)

Is this an expression that returns a string from the object [SomethingElse] or is it a global expression that does some manipulation on the string “SomethingElse”?

It might be obvious to the user that made the code but other users reading had a hard time figuring out the meaning.

It got even more convoluted when you wanted to chain the result of expressions together:
someExpression(anotherExpression$(moreExpressions(lastExpression$())))

It can be read as something along the way of, the “someExpression” of “anotherExpression” as a result of “moreExpressions” on “lastExpression”. While it is a valid and perfectly fine way of explaining it, it also requires you to remember the entire expression at once to get the meaning.

New syntax

As we have talked about before we are changing the expression syntax to be more “functional”. If you want to retrieve data from something you first type the name of that something and then what you want to get.

Instead of Len(“SomeString”) you now type “SomeString”.length
Instead of X(“MySprite”) you now type MySprite.x

This has several benefits to you. You can chain expressions together easier and we can now show you intelligent code completion.

expreditor

In the above animation you can see how typing “ColorRGBA.” gives you a popup that show you available options for that type. “Yellow” is a convenient static property of “ColorRGBA” so we can select that one. We now have the yellow color which we can then access. You can see we have the ‘r’, ‘g’, ‘b’ and ‘a’ values available from it which are “float” components of the color.

Now we can chain the expressions even further by getting another color from our yellow color. The expression “withAlpha” simply returns a version of that color but with the alpha component replaced with the one we give it.

To demonstrate the point about how easy it is to chain expressions together we go all the way and convert the color to a string and list some of the available string operations you can do.

We have a lot of powerful functionality ready in our basic types that we haven’t made available to the editor yet. Stay tuned for more cool examples!

We’d love to hear your comments on our blog posts and on our development. Throw us a mention on Twitter or Facebook and tell us what you think!

https://twitter.com/Clickteam

https://www.facebook.com/clickteam/