arcalot / arcaflow-expressions

Expressions language for Arcaflow
Apache License 2.0
0 stars 0 forks source link

Mathematical Expressions #3

Open jaredoconnell opened 1 year ago

jaredoconnell commented 1 year ago

Please describe what you would like to see in this project

The expression language should support basic mathematical expressions. They would be supported within expressions where literals and variables were allowed before. They are binary operators, so there is one variable or literal each on the left and right, with the binary operator in the middle.

The standard PEMDAS order of operations will be supported.

Supported binray mathematical operations:

Potential supported binary operation, if easy to add:

Potential supported operation: Order of operation parentheses.

Typing

Non-numeric types

Math is exclusively for numeric types, so Integer and Float. Upon input of a non-numeric type, it will output a type error.

Mismatching Numeric Types

Due to the inherit loss of precision between float and integer, a type error will be raised in the event of ints and floats being used together. Type conversions would require calling a type conversion function, as would be enabled by #1

Unit data

In the case of units, it will manipulate using the base unit. It may make sense to enforce units that are being interacted with. For example, it may be okay to multiply seconds by 5, but not okay to add 5 seconds to 5 bytes.

Please describe your use case

The most obvious use case is to allow mathematical manipulation from input or step output, to be used for some other input or output. For example, if you have two steps that have a duration input, and you want one step to last 10 seconds longer than the other, it makes more sense to add 10 to the duration input than to have the workflow designers and users manage two variables.

Additional context

This is a lower priority task than #1 and #2. A lot of the work for #2 will likely be similar to this work because both tasks are requesting the implementation of binary operators. Therefore, the additional work created by this task will likely not be too great.

janosdebugs commented 1 year ago

@jaredoconnell a few notes:

  1. Please add details how this will work with non-numeric types.
  2. I'd remove the implicit type conversion, we should add explicit conversion functions for that. Floats loose precision in operations.