You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project:
The Expression Parser does not support ** as a pow operator. While pow(a,b) may have a better readability when used in a complex expression it is way slower to write than a**b. Especially in the case of Input fields, where the expression is lost after submitting, I don't think a lot of people will write smaller expressions more often then complex ones.
With pull request godotengine/godot#42376, this problem is increased due to commas no longer working in EditorSpinSlider.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Add ** to the operators for the Expression.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
In expression.cpp:
Add Token TK_OP_POW in _get_token and the operator switch in _parse_expression.
Add Variant OP_POW, here we need to put it between OP_NEGATE and OP_MULTIPLY i.e. increase the priority for everything >= OP_MULTIPLY by one and give OP_POWpriority = 1.
In variant_op.cpp:
Add OP_POW to CASES(PREFIX), in evaluate the basic Case is obviously numbers, but at least for a**b, b ∈ ℤ most things that work for Multiplication could be adopted, this would make this more versatile than the pow function.
If this enhancement will not be used often, can it be worked around with a few lines of code
The basic version should be about 20 lines of code, implementing more functionality would increase that by a bit.
Is there a reason why this should be core and not an add-on in the asset library?:
It could not be easily done by an add-on, and it could be implemented parallel to #1045, so that both gdscript and the number input use the same syntax.
I am able to make a pull request for this, at least for a basic numbers only version.
The text was updated successfully, but these errors were encountered:
Describe the project you are working on:
A Game
Describe the problem or limitation you are having in your project:
The
Expression
Parser does not support**
as apow
operator. Whilepow(a,b)
may have a better readability when used in a complex expression it is way slower to write thana**b
. Especially in the case of Input fields, where the expression is lost after submitting, I don't think a lot of people will write smaller expressions more often then complex ones.With pull request godotengine/godot#42376, this problem is increased due to commas no longer working in EditorSpinSlider.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Add
**
to the operators for theExpression
.Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
In
expression.cpp
:Add Token
TK_OP_POW
in_get_token
and the operator switch in_parse_expression
.Add Variant
OP_POW
, here we need to put it betweenOP_NEGATE
andOP_MULTIPLY
i.e. increase thepriority
for everything >=OP_MULTIPLY
by one and giveOP_POW
priority = 1
.In
variant_op.cpp
:Add
OP_POW
toCASES(PREFIX)
, inevaluate
the basic Case is obviously numbers, but at least fora**b, b ∈ ℤ
most things that work for Multiplication could be adopted, this would make this more versatile than thepow
function.If this enhancement will not be used often, can it be worked around with a few lines of code
The basic version should be about 20 lines of code, implementing more functionality would increase that by a bit.
Is there a reason why this should be core and not an add-on in the asset library?:
It could not be easily done by an add-on, and it could be implemented parallel to #1045, so that both gdscript and the number input use the same syntax.
I am able to make a pull request for this, at least for a basic numbers only version.
The text was updated successfully, but these errors were encountered: