MVEL
  1. MVEL
  2. MVEL-260

Support more commonly-used null-safe property navigation syntax

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Currently in order to make a null safe property navigation, the syntax is ?nullSafeProperty.property
      For example, foo.?bar.p
      means foo.bar == null ? null : foo.bar.p

      There are many scripting language adopting a different syntax: ?.
      The above example becomes: foo.bar?.p
      which is more intuitive because
      1) the null-checking ( ? ) is put together with the corresponding navigation (.) . Existing syntax of MVEL is a bit misleading because .? seems to come together, but in fact the latter ? affects the next navigation.
      2) The syntax (?.) can be easily understand by "reading" as : is not null ( ? ) then navigate (.)

      It seems to me both syntax can coexists in order to maintain backward compatibility.

      For example
      foo.?bar.apple?.?boy.car

      seems interpretable.

        Activity

        Hide
        Adrian Shum added a comment -

        JIRA is converting ( ? ) to an icon .. Please interpret all red question mark icon as ( ? )

        Show
        Adrian Shum added a comment - JIRA is converting ( ? ) to an icon .. Please interpret all red question mark icon as ( ? )
        Hide
        Adrian Shum added a comment -

        Just wonder if there is any plan for this feature? I hope it is coming out soon

        Show
        Adrian Shum added a comment - Just wonder if there is any plan for this feature? I hope it is coming out soon

          People

          • Assignee:
            Mike Brock
            Reporter:
            Adrian Shum
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: