TomFrost / Jexl

Javascript Expression Language: Powerful context-based expression parser and evaluator
MIT License
559 stars 90 forks source link

Opinions on functions vs transforms? #102

Closed cmdcolin closed 3 years ago

cmdcolin commented 3 years ago

Great work on this library. I was wondering about your perspective on functions vs transforms

The readme suggests: "While Transforms are the preferred way to change one value into another value, Jexl also allows top-level expression functions to be defined"

And I see that functions are actually a recent addition, so this is pretty cool, but do you have any reasons why transforms would be preferred?

TomFrost commented 3 years ago

Hi Colin!

At the end of the day it all boils down to personal preference, as there's no functional advantage to one over the other. The readme suggests transforms for two main reasons:

So there you have it! If the function syntax makes more sense to you and anyone you have that might be writing these expressions, by all means you should use that :). If the above reasons could be impactful for you, though, transforms still have a nice place within the language definition.

Enjoy!

cmdcolin commented 3 years ago

gotcha thanks so much :)

TomFrost commented 3 years ago

You're welcome! :)