TheZipCreator
New member
- Joined
- Jan 11, 2021
- Messages
- 6
- Reaction score
- 0
Expressions
An expression would basically be a mathematical statement that is evaluated at runtime. Currently, we have all the "text codes" which basically do this, but they're a bit inconvenient and unwieldy. Instead, I propose a new variable type called expressions, which make this much more streamlined.
An example expression would be
which, under the current system is represented, rather annoyingly, as
. Looking at both of those, you can probably tell which one is better. This could also replace the %index text code with array subscripting, e.g.
=
. Subscripting matrices (lists of lists) would be done like this:
, which is equivalent to
.
You could also introduce comparisons and logical operators, and then have an "if expression" added to if var and repeat. So, you could for example, run code if
, which can help save space.
You could also add string literals in addition to numbers, so
evaluates to a string. Combining this with subscripting, you could index into a dictionary with
. There's also the issue of how to deal with variables names that have spaces in them. In order to do this, you would use { and }. Inside { and }, typical DF text codes will work. Ex:
.
An expression would basically be a mathematical statement that is evaluated at runtime. Currently, we have all the "text codes" which basically do this, but they're a bit inconvenient and unwieldy. Instead, I propose a new variable type called expressions, which make this much more streamlined.
An example expression would be
Code:
x+(y*3)
Code:
%math(%var(x)+(%var(y)*3))
Code:
arr[x]
Code:
%index(arr,%var(x))
Code:
arr[2][3]
Code:
%index(%index(arr,2),3)
You could also introduce comparisons and logical operators, and then have an "if expression" added to if var and repeat. So, you could for example, run code if
Code:
(i == 1) || (i == 16)
You could also add string literals in addition to numbers, so
Code:
"Hello, World!"
Code:
dict["myKey"]
Code:
{%default i}+5
Last edited: