Difference between $countones and user defined countones function in constraints

I see that there is a difference in how $countones & user defined countones functions behave in constraints. using $countones we can enforce number of '1s to be randomized in a bit-vector, where as using countones() function there is only option to count the number of ones, can’t enforce the required number of '1s. I assume this is because of the fact that functions are not bidirectional in constraints, isn’t the $countones() considered as function?

In reply to yourcheers:

$countones is a built-in system function and the constraint solver has pre-defined mechanisms for converting the function into a Boolean equation. That allows the random variables used in the inputs to the function to be solved simultaneously with the random variables constrained by the output of the system function.