Conversation
Todo: We need to have a concept for generating temporal variable ids without nameclash The transpilation is inspired how EEL does it: https://github.com/neos/flow-development-collection/blob/70bc49cc946c443dadfe26c49a19d710ece4ad48/Neos.Eel/Classes/CompilingEelParser.php#L163-L180 simplified the eel transpilation of or would look like: `($leftExpressionResult = $leftExpression) ? $leftExpressionResult : $rightExpression`
|| and && correctly to php (with ecmascript behaviour)
|| and && correctly to php (with ecmascript behaviour)|| and && correctly to php (with ecmascript behaviour)
Member
|
This is somewhat similar in spirit to #8, in that I'd also like to suggest to deviate from ECMAScript behavior and opt for the imho more obvious behavior of PHP (boolean operation -> boolean result). |
Contributor
Author
|
Yes we discussed this and i agree. We could always introduce the I think that php and js have a different truthy and falsy behaviour is The only difference, that might cause trouble, is that I will close this discussion for know ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The proposed expected php transpilation is inspired how EEL archieves it:
https://github.com/neos/flow-development-collection/blob/70bc49cc946c443dadfe26c49a19d710ece4ad48/Neos.Eel/Classes/CompilingEelParser.php#L163-L180
the simplified eel transpilation of "||" would look like:
($leftExpressionResult = $leftExpression) ? $leftExpressionResult : $rightExpressionTodo:
While thinking of other differences in php and javascript, the truthyness came to my mind.
If we are not carefull a string
"0"will be considered by the transpiled php falsy instead of truthy (by es standard)The biggest problem is see, is that our testcases will be obscurified. Currently its super easy to read them as they nearly transpile 1 to 1 to php. But when we want ecmascript behaviour we need to use our own truthy helpers and transpile "and" and "or" correctly. This will lead to more bloat in the transpilation everywhere. We currently mostly test the AST and parsing by asserting the transpilation worked correctly, and if we want to write less transpilation tests we dont test the parsing that extensively anymore. Maybe we can build an easy back to AFX transpiler so we know that parsing worked without asserting the AST structure?