Skip to content

Comments

Use functions as properties may not necessarily be defined when copy constructing meta#548

Merged
amontoison merged 2 commits intoJuliaSmoothOptimizers:mainfrom
apozharski:ap/funs-instead-of-getproperty
Feb 23, 2026
Merged

Use functions as properties may not necessarily be defined when copy constructing meta#548
amontoison merged 2 commits intoJuliaSmoothOptimizers:mainfrom
apozharski:ap/funs-instead-of-getproperty

Conversation

@apozharski
Copy link
Contributor

No description provided.

@amontoison
Copy link
Member

Should we add some fallbacks here in NLPModels.jl?

@apozharski
Copy link
Contributor Author

apozharski commented Feb 21, 2026

for field in fieldnames(NLPModelMeta)
meth = Symbol("get_", field)
@eval begin
@doc """
$($meth)(nlp)
$($meth)(meta)
Return the value $($(QuoteNode(field))) from meta or nlp.meta.
"""
$meth(meta::AbstractNLPModelMeta) = getproperty(meta, $(QuoteNode(field)))
end
@eval $meth(nlp::AbstractNLPModel) = $meth(nlp.meta)
@eval export $meth
end

I think these lines create fallbacks for all of these already. Perhaps though there are some things in tools.jl that should be using the get_* functions as well to be sufficiently generic, let me checK.

@amontoison amontoison merged commit 6bdaf27 into JuliaSmoothOptimizers:main Feb 23, 2026
73 checks passed
@amontoison
Copy link
Member

Thanks @apozharski !
I will finalize #540 this week and do a patch release 0.21.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants