[m-rev.] for review: reversing operator priorities

Zoltan Somogyi zoltan.somogyi at runbox.com
Sat Nov 12 00:56:10 AEDT 2022



On Fri, 11 Nov 2022 13:18:53 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
> > library/string.m:
> >     Add a note on an significant old problem.
> 
> The diff does not contain any changes to string.m

It is in the commit; I must have included a pre-final
diff in my email.

> >          % Check whether a string is the name of an operator.
> >          %
> > +        % XXX operating system
> 
> operating system?

That was supposed to be "XXX OPS", but it seems that in that
vim session, I forgot to disable my vim macro that automatically
expands OPS to operating system.

The point of that XXX is that the name lookup_op is misleading.
First, lookup_up is a semidet predicate, while everywhere else
in the library lookup names det operations. Second, it does not
return anything; it merely tests whether the given string is an operator
in the given table. I would suggest renaming to something
like is_operator or is_op.

> > -    % The Mercury operator table used to be the only one allowed.
> > -    % The old names are no longer appropriate.
> > +    % We export this type synonym to io.m (for get_op_table/set_op_table)
> 
> The whole setup with io.get/set_op_table seems clunky.

Agreed.

> The only user of
> io.get_op_table is term_io and it could just call ops.init_mercury_op_table
> directly. It's not clear to me why io.get/set_op_table need to exist.

Nor to me. Should we mark them as obsolete? I think so.

> (Was it required to support user-defined operators some time in the past?)

I think that may have been the intention, but as the comment explains,
this mechanism would not have allowed any operator table except the
the returned by init_mercury_op_table.

I followed your (and Peter's) other suggestions, as shown by the attached
log and diff.

Zoltan.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.oprev3
Type: application/octet-stream
Size: 308 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20221112/2f3d14bf/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.oprev3
Type: application/octet-stream
Size: 14288 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20221112/2f3d14bf/attachment-0003.obj>


More information about the reviews mailing list