1

I had this

return $(check-age-name-date($File) -or $(check-name-debugtxt($File) -and check-age-last-mod($File)))

looks very straight-forward to me, but I had to change it to:

if(check-age-name-date($File)) {
    return $True
} else {
    if(check-name-debugtxt($File)){
        if(check-age-last-mod($File)){
            return $True
        }else{
            return $False
        }
    } else {
        return $False
    }
}

it just never executed check-age-last-mod. If check-age-name-date was false and check-name-debugtxt was true, it just returns true without invoking check-age-last-mod at all!!! What's going on here?

To clarify, the first piece of code is broken, the second one works, but is way longer. I just want explanation, because I'm surely missing something fundamental here. I'm not comfortable using language where I don't understand it's predicate logic.

1 Answer 1

2

You need some more brackets:

return $((check-age-name-date($File)) -or ((check-name-debugtxt($File)) -and (check-age-last-mod($File))))

Simplistically what you have is:

$a -or ($b -and $c)

But because you're calling functions you need to evaluate the result of each of them before the comparison, therefore you need to wrap each function call in brackets too, so you have

(f($a)) -or ((f($b)) -and (f($c)))

And because you want to evaluate the entire thing, that also needs be wrapped in parenthesis

((f($a)) -or ((f($b)) -and (f($c))))
Sign up to request clarification or add additional context in comments.

2 Comments

Wow, <..insert sarcastic lisp comments here..>... Anyway, it works! Thanks a lot!
Assuming that the functions are user-defined functions the innermost parentheses are not required. ((f $a) -or ((f $b) -and (f $c))) should suffice, making the condition a little more readable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.