• Hey! Register here to create your account, engage with the community, and talk about what is new!

Expressions

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
Code:
x+(y*3)
which, under the current system is represented, rather annoyingly, as
Code:
%math(%var(x)+(%var(y)*3))
. 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.
Code:
arr[x]
=
Code:
%index(arr,%var(x))
. Subscripting matrices (lists of lists) would be done like this:
Code:
arr[2][3]
, which is equivalent to
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)
, which can help save space.
You could also add string literals in addition to numbers, so
Code:
"Hello, World!"
evaluates to a string. Combining this with subscripting, you could index into a dictionary with
Code:
dict["myKey"]
. 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:
Code:
{%default i}+5
.
 
Last edited:

pixlii

Forum adept
Overlord
Joined
May 20, 2021
Messages
215
Reaction score
34
something similar has been suggested (the thread is called %{}) and it has received lots of support. i like this too, it would help make coding SO MUCH simpler.
 
Top Bottom