Is this 'if' statement supposed to work?

I was trying to make special mutex guards for my needs. And I wanted to test if it is possible to guard multiple mutexes in single ‘if’ statement and found that sample code below works with two or even more guards:

bar :: proc () {
    fmt.println("Inside bar")
}

@(deferred_none=bar)
foor :: proc () -> bool {
    fmt.println("Inside foo-r")
    return true
}

baz :: proc () {
    fmt.println("Inside BAZ")
}

@(deferred_none=baz)
fooz :: proc () -> bool {
    fmt.println("Inside foo-z")
    return true
}

a :: proc () {
    if foor() & fooz() {
        log.info("Guarding with foo-r and foo-z")
    }
    fmt.println("Leaving a")
}

Yes because all calls to foor() and fooz() are handled, unlike with &&.

1 Like