Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expressions - JS vs PHP evaluator - incompatibility #118

Open
Jemt opened this issue Aug 16, 2019 · 0 comments
Open

Expressions - JS vs PHP evaluator - incompatibility #118

Jemt opened this issue Aug 16, 2019 · 0 comments
Labels
Milestone

Comments

@Jemt
Copy link
Owner

Jemt commented Aug 16, 2019

Expressions in JSShop must be compatible with both JS and PHP.

Currently we have a problem with string concat.
PHP: $val = $str1 . $str2 for strings, $val = $int1 + $int2 for numeric values.
vs
JS val = str1 + str2 for strings AND numeric values.

The expression engine takes care of "transpiling" from JS syntax to PHP which is fairly easy for identifiers (str1 => $str1), but determining whether to use . (dot) or + (plus) is more difficult.

Also, JS' ternary operator is right-associative (like all sane languages) while PHP's is left-associative: https://stackoverflow.com/questions/20559150/ternary-operator-left-associativity

image

While we can construct the short-hand conditional expression in a way that works with both JS and PHP, inconsistency is not acceptable.

We might have to disable support for generic expressions, and enforce use of functions to do even simple things - e.g.:

JSShop.Add(a:numeric, b:numeric)
JSShop.Substract(a:numeric, b:numeric)
JSShop.Multiply(a:numeric, b:numeric)
JSShop.Concat(str1:object, str2:object)

JSShop.Concat("Result: ", JSShop.Multiply(JSShop.Add(a, b), 3.14))
@Jemt Jemt added the bug label Aug 16, 2019
@Jemt Jemt added this to the SMCMS-JSShop milestone Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant