Supporting Timespan math operations #4720
Replies: 4 comments 4 replies
-
I like proposal 1. You could possibly just take in %object% for the ExprArithmetic patterns. From there you could just check if its instanceof Number or Timespan, which will make it easier to add support for things later. The only downside I see to this is that you won't get any error at init for |
Beta Was this translation helpful? Give feedback.
-
Proposal 1 is by far the most suitable. That said, multiplication leaves some discussion as a timespan technically has a unit attached to it, unlike numbers. There should, however, be a general implementation that supports all number-like types. This means that any type that has an arithmetic operations registered and uses itself as the change type, should automatically have this functionality.
This way all addon developers can hook into this system. Another huge advantage is that the vector math expression can all be reduced and added to this system! |
Beta Was this translation helpful? Give feedback.
-
I'm not familiar with ExprArithmetic or timespans, but couldn't we just make timespans implement Number, returning their tick values as needed? |
Beta Was this translation helpful? Give feedback.
-
IMO the implementation should be done by making ExprArithmetic take %object%, then check at runtime if the return type of the given expression has arithmetic (or is Object.class). We should also extend the Arithmetic class by adding a method like acceptsOperation to check if it e.g. supports multiplication, division and exponentiation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
💡 Would you like to support Timespan in math operations? see example below
How it looks
🔹 What to be able to do
send "%10 seconds - difference between {_t1} and {_t2}%"
🔸 Instead of
More examples:
🔹 Proposal 01
Supporting this in ExprArithmetic, this will allow all kind of math operations between Timespans such as
/ * - + ^
🔹 Proposal 02
Only supporting addition and subtraction, probably by making a new expression for this feature
🔹 Proposal 03
Making it english-like expression, something like
time[span] left of %timespan% from %timespans%
- subtractiontime[span] from %timespan% and %timespans%
- additionBeta Was this translation helpful? Give feedback.
All reactions