This behavior seems like it is "as advertised"? I see in the documentation:

"Flow- and logic-functions store the result of their controlling expression - respectively non-NIL results of their conditional expression - in @."

So the case when (sym? A2) seemingly would not update the current value of @, and...

"@ is generally local to functions and methods, its value is automatically saved upon function entry and restored at exit."

No function has been entered or exited here, unless I'm misunderstanding what constitutes a function.

-wilhelm

On 2/8/22 9:15 AM, Kevin Ednalino wrote:
Hello,

I may have encountered a possible bug, unless my understanding of @ is incorrect. It appears the value of @ is not restored in a prog1 body when another flow/logic statement occurs as the car of an expression within the said prog1 body. In both cases, the correct result is returned from prog1.

Test Cases:

  (let (A0 (1)
        A1 (2 3)
        A2 'x)
    (prog1 (cdr A1)
      ((if (sym? A2) 'set 'con) A2 A0)
      # Prints T when sym? result is T (incorrect)
      # but prints (3) when sym? result is NIL (correct)
      # Expect (3) printed regardless of sym? result
      (println @)))

  (let (A0 (1)
        A1 (2 3)
        A2 (4))
    (prog1 (cdr A1)
      ((if (sym? A2) 'set 'con) A2 A0)
      # Prints T when sym? result is T (incorrect)
      # but prints (3) when sym? result is NIL (correct)
      # Expect (3) printed regardless of sym? result
      (println @)))

Thanks,
Kevin

Reply via email to