register modifies its argument model, so the function would normally end in
!. Why isn’t this function named
The JuMP style guide covers this: Style Guide · JuMP.
!when the name itself makes it clear that modification is taking place, e.g.,
set_name. We depart from the Julia style guide because
!does not provide a reader with any additional information in this case, and adherence to this convention is not uniform even in base Julia itself (consider
For what it’s worth — I normally expect a function like
sort to return a modified value without actually mutating the argument. I imagine a functional API like this could exist for JuMP too, so I was surprised to see
register used with no return value. So I’m not sure the name tells users what the function does if they don’t already know, especially in the context of such a strong convention.
Unfortunately not. Mutation is a core part of the design, so there will probably never be a purely functional API to JuMP.