Why isn't JuMP.register named register!

register modifies its argument model, so the function would normally end in !. Why isn’t this function named register!?

1 Like

The JuMP style guide covers this: Style Guide · JuMP.

Omit ! when the name itself makes it clear that modification is taking place, e.g., add_constraint and 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 Base.println and Base.finalize).

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.

1 Like

Unfortunately not. Mutation is a core part of the design, so there will probably never be a purely functional API to JuMP.