Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: evaluation order?

  1. #1
    Senior Member
    Join Date
    Oct 2012
    Posts
    125

    evaluation order?

    does Lianja have defined evaluation order for the "IF" statement? Can it be assumed that if ".AND." in an "IF" statement connects two logical expressions, and the first (or the second, depending on the order of evaluation) is FALSE, then the second is not evaluated?

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,010
    Hi Strato,

    Evaluation is left-to-right per the Logical Operators section in this doc: https://www.lianja.com/doc/index.php/Lianja_Operators

    If you find that not to be the case, write up a simple example that replicates the discrepancy and report in a ticket.

    By writing a simple example you will double-check that it's not another error in your code. I learned that after the first few (or more -- I'm sorry, Yronne, really I am) turned out to some other things in my code.

    Hank
    Last edited by HankFay; 2020-09-27 at 15:35.

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,966
    You can experiment with these types of things in the console.

    type this:

    ? .t. or orjhkjhkjhkjh()

    then


    ? .f. or orjhkjhkjhkjh()

    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Senior Member
    Join Date
    Oct 2012
    Posts
    125
    You are absolutely right Hank!
    Here are these examples. (The first 2 are related to "IF", the third is a slightly different problem). The problem is that it doesn't always run that way. I am probably doing something very wrong that puts Lianja in such a state. So I can't send an error ticket yet
    The third example is interesting because if the variable "a" is "private", then there is no error. However, I think something is wrong because the formal parameter "x" must exist in all cases. There may not be a problem with the evaluation order here, although the error only occurs when fx (fx ()) is the structure.
    Attached Images Attached Images    

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,966
    You have clearly been running something that has changed settings as this works perfectly fine for me.

    Name:  Screen Shot 2020-09-28 at 1.10.11 PM.jpg
Views: 37
Size:  17.5 KB
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Senior Member
    Join Date
    Oct 2012
    Posts
    125
    dear Barry,
    do you have any idea what setting might affect the evaluation algorithm? Where do I look for the bug?

  7. #7
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,010
    Hi strato,

    In your last example, you are declaring a as a local var. Why, you say? Because the default in Lianja thankfully is local. So. fix2(a) is where it would fail, as that's a level down.

    Hank

  8. #8
    Senior Member
    Join Date
    Oct 2012
    Posts
    125
    I donít think it matters whether a variable is explicitly or automatically declared local. But I think the operation of a function cannot be affected by whether the current parameter is local or private (or global). Otherwise, this is indeed the case if the current parameter is a variable and not a function. But I think in the example, the parameter of the fx1 () function is 2 local values, even if we describe them as expressions. (I don't want to pass the variable "a" to the fx1 () file in either version. But it seems to happen.)Name:  precedence_error_4.png
Views: 29
Size:  32.5 KB

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,966
    Its not a bug. To cause all terms in a logical expression to be evaluated you can turn off logical expression optimization.

    set optlog off

    Thats what you must have done. That command is there to better test all terms of a logical expression and is typically not used in production.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  10. #10
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,966
    The error is correct. The execution level of a function call in a parameter list is higher. if you don't want that behavior use macros.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Page 1 of 2 12 LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us