Page 1 of 1

User defined functions in expressions?

Posted: Sun Apr 22, 2018 7:39 pm
by mcornholio
I think, it would be pretty cool to let user to save and reuse arbitrary expression functions.

For example , I use

Code: Select all

sqrt(x*500)*5000 % 1
as random from seed. I could save it to

Code: Select all

random(x)
and use it in all my scenes.

While exprtk allows user defined functions: https://github.com/ArashPartow/exprtk/b ... .txt#L1803, their user-definition is compile-time and written in C++, so not our option.

What I think is more like preprocessor macros.
So, if user defines

Code: Select all

func wat(a, b, c) = (a + b) * c
and when user writes

Code: Select all

wat(1,2,3)
in the expression, Magic converts it to

Code: Select all

(1 + 2) * 3
before execution.

Sounds not so hard, right?

Re: User defined functions in expressions?

Posted: Mon Apr 23, 2018 3:55 pm
by Magic
Everything is hard :). But yes, it seems like a reasonable idea. It would require some kind of new editor though.