Note:- I'm not talking about Increment & Decrement Operator. I'm talking about prefix & postfix expressions.
Example in python:-
def calculate(a, b, c, d):
return a * ( b + c ) / d
calculate(1,2,3,4)
I know that python doesn't support prefix or postfix expressions. But imagine if python supports postfix expression, I can write the function like this
def calculate(a, b, c, d):
return a b c + * d /
calculate(1,2,3,4)
I read in this link that evaluating the postfix expressions are faster than infix expressions
- The time required for evaluating an infix expression is O(n^2) -> reason - Need to find the operators having the highest precedence.
- The time required for evaluation of postfix expression is O(n) -> reason - No need to find the precedence of operators. We just need to evaluate from left to right.
If this is the case then why don't popular programming languages like C, C++, Java, Python, Ruby, or PHP support postfix expressions natively?