NAV (CA/l) should use short-circuit evaluation

miOnKeybmiOnKeyb Member Posts: 13
Why in 2018 doesn't MS "upgrade" C/AL to use short-circuit evaluation?
IF Customer.GET('1000') and Customer."No."='1234' THEN Die();
I hate the 90's ....

Answers

  • rahul_jnkrahul_jnk Member Posts: 61
    Hi mionKeyb,

    The above is a database operation. IMHO NAV has made it so easy to fetch data from database with relatively simple commands.

    I don't get what you imply by
    Customer.GET('1000') and Customer."No."='1234'

    you mean customer who has No. 1000 and 1234 that doesn't make sense :/

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    miOnKeyb wrote: »
    Why in 2018 doesn't MS "upgrade" C/AL to use short-circuit evaluation?
    Maybe because it's been like that since NAV was initially released, and is it possible that some code may rely on old expression evaluation? Not on only Microsoft's code base, it could well be in customizations / addons code too.

    Can you imagine the burden put on all partners by introducing such a fundamental change? It would require everybody to conduct detailed code review and analysis, and potentially rewrite and test changes.

    Since you know that NAV does use short-circuit evaluation write your code in a way to avoid constructs where lack of it may cause potential problems.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • afarrafarr Member Posts: 287
    As pointed out in Wikipedia, the short-circuit expression "x and y" is equivalent to
    if x then y else false
    

    The short-circuit expression "x or y" is equivalent to:
    if x then true else y
    

    So you can write equivalent code if it's so important, although I acknowledge that its not as elegant.
    Alastair Farrugia
Sign In or Register to comment.