You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a request to revisit how we represent partial and explicit template specializations in IPR.
Specifically how secondary templates and entities that resulted from explicit specializations indicate what is their primary template and an argument list and where specializations are stored (in the scope and subject to name+type lookup or in the specializations list).
Prior to commit Simplify ipr::Decl a bit, every declaration would carry an information whether it was produced by a specialization of a template and if so what were the arguments:
this was used to by some users of IPR to figure out whether a given declaration is an explicit specialization of a template or non-templated declaration (by checking if the substitution.size() > 0) or to distinguish between the primary or secondary template using the same technique for ipr::Template declaration.
We no longer have this mechanism.
There is an args field in struct Template : impl::Decl<ipr::Template>
IPR user-guide gives an example of how to create primary and secondary templates and in that example it populates the args array with template args referring to the parameters in the mapping that is the body of that particular template i.e. a different mechanism than ipr::Substitution that are used to indicate template arguments in ipr::Decl where they would always refer to the parameters of the primary template.
However the existing args field of ipr::impl::Template is not exposed via ipr::Template and therefore not available to ipr consumers.
There is no way to indicate what is the primary template when defining a secondary template. There is an FIXME in the implementation of make_secondary_template
which makes me think that the intention was to capture a reference to a primary_template which leads to
Do arguments to make_secondary template make sense?
Should they be, for example, make_secondary(ipr::Template& primary, Expr_list& args, const ipr::Forall& t) for example and not what we currently have make_secondary_template(const ipr::Name& n, const ipr::Forall& t).
Should we be adding secondary templates to the overload set?
In the code fragment mentioned earlier, we can see that we are adding the secondary template to an overload set for the name n and adding the declaration to that scope, whereas I believe the intention was to link all specializations to the specs field of the master declaration of the primary template struct master_decl_data<ipr::Template>:
This is a request to revisit how we represent partial and explicit template specializations in IPR.
Specifically how secondary templates and entities that resulted from explicit specializations indicate what is their primary template and an argument list and where specializations are stored (in the scope and subject to name+type lookup or in the specializations list).
this was used to by some users of IPR to figure out whether a given declaration is an explicit specialization of a template or non-templated declaration (by checking if the substitution.size() > 0) or to distinguish between the primary or secondary template using the same technique for ipr::Template declaration.
We no longer have this mechanism.
args
field instruct Template : impl::Decl<ipr::Template>
ipr/include/ipr/impl
Line 1390 in 9e60541
IPR user-guide gives an example of how to create primary and secondary templates and in that example it populates the args array with template args referring to the parameters in the mapping that is the body of that particular template i.e. a different mechanism than
ipr::Substitution
that are used to indicate template arguments in ipr::Decl where they would always refer to the parameters of the primary template.However the existing
args
field ofipr::impl::Template
is not exposed viaipr::Template
and therefore not available to ipr consumers.make_secondary_template
ipr/src/impl.cxx
Lines 1295 to 1313 in 9e60541
which makes me think that the intention was to capture a reference to a primary_template which leads to
Should they be, for example,
make_secondary(ipr::Template& primary, Expr_list& args, const ipr::Forall& t)
for example and not what we currently havemake_secondary_template(const ipr::Name& n, const ipr::Forall& t)
.In the code fragment mentioned earlier, we can see that we are adding the secondary template to an overload set for the name
n
and adding the declaration to that scope, whereas I believe the intention was to link all specializations to thespecs
field of the master declaration of the primary templatestruct master_decl_data<ipr::Template>
:ipr/include/ipr/impl
Lines 552 to 553 in 9e60541
The text was updated successfully, but these errors were encountered: