flow-development-collection icon indicating copy to clipboard operation
flow-development-collection copied to clipboard

Eel Null Coalescing Operator

Open mhsdesign opened this issue 3 years ago • 2 comments

Description

Currently one often needs to write the following code in fusion eel:

{foo != null ? foo : bar}

in php this could be better written like

$foo ?? $bar;

im proposing to implement this Null Coalescing Operator in eel:

{foo ?? bar}

The eel parser https://github.com/neos/flow-development-collection/blob/68321067e83dc82702d266f6b27b4f4afad54186/Neos.Eel/Resources/Private/Grammar/Eel.peg.inc#L43 and the CompilingEelParser https://github.com/neos/flow-development-collection/blob/68321067e83dc82702d266f6b27b4f4afad54186/Neos.Eel/Classes/CompilingEelParser.php#L293 should be extended. (Those snippets show the ternary eel)

I would not implement this in the InterpretedEelParser.php as this one is not used and should probably be removed.

mhsdesign avatar Mar 02 '22 21:03 mhsdesign

I think you mean {foo != null ? foo : bar} in your example

jonnitto avatar Mar 03 '22 07:03 jonnitto

btw concerning fusion woulndt this be cool?

path ??= 'hello'

->

[email protected] = ${value ?? 'hello'}

edit: this was more of a Schnapsidee as it makes things less transparent and harder to learn

mhsdesign avatar Mar 08 '22 07:03 mhsdesign