[m-rev.] for post-commit review: new pragma type_order_switch
Zoltan Somogyi
zoltan.somogyi at runbox.com
Wed Jun 18 15:14:05 AEST 2025
On Wed, 18 Jun 2025 15:01:10 +1000, Julien Fischer <jfischer at opturion.com> wrote:
> On Tue, 17 Jun 2025 at 23:35, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> >
> > I intend to use this new pragma to ensure that the order
> > of the clauses of the optdb predicate matches the order
> > of the options they describe in the option type.
> >
> > The implementation is straightforward, and thus does not
> > really need review. The questions I would like reviewers
> > to look at are:
> >
> > Is this pragma useful generally enough to be publicly documented?
>
> I think so. Would it be more useful as a scope around a switch, rather
> than a pragma on the predicate.
That was my first thought as well. But that does not work when the switch
is constructed not from an explicit disjunction, but the disjunction implicit
in a whole bunch of clauses. And in this case, unlike many others, I think
clauses are preferable to an explicit disjunction.
Of course, I can add it as a scope as well. However, that does bring up
an issue: if we allow people to nest e.g. this new scope inside another
switch-related scope such as require_switch_arms_semidet, which we should,
we need to ensure that their implementations support that. I don't think they do,
at the moment.
> (We already have a bunch of such scopes.)
I know. I added them all :-)
> > Can anyone think of a better name for the pragma?
>
> In line with other pragmas / scopes, it probably wants to be
> "require_" something.
> Perhaps, "require_switch_type_order"?
How about require switch_arms_in_type_order? A bit longer,
but a lot more descriptive.
> > Can anyone think of any way to improve the wording of the
> > warning message?
>
> Not so much an improvement, but don't we refer to "cases" as "arms"
> elsewhere?
I know we do, but I think we may refer to cases as well. I will have a look
at the manuals, and act according to what I find.
Thanks for the review.
Zoltan.
More information about the reviews
mailing list