[JuMP] Get variable name from a model to use on another

On JuMP, I have a model

m = Model()
@variable(m, x[1:2])

By passing m to a function, can I obtain the variable x to define a new model with x?

can I obtain the variable x

Yes m[:x].

to define a new model with x?

No. x belongs to the model m.

Do you want to make a variable with the same name? Or bounds? Or indices? If so, just pass the necessary data to build the variable rather than the model and actual variable.

Thanks @odow, but I must clarify. I don’t know which variables the model has, that is, instead of defining x, an user could define only y.

This is related to another problem and the context is clearer there.

Solved in the other post.