[m-dev.] pragmas should specify pred/func as well as name and arity
Peter Wang
novalazy at gmail.com
Thu Apr 29 15:54:58 AEST 2021
On Thu, 29 Apr 2021 15:25:12 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
>
>
> On Thu, 29 Apr 2021 15:16:28 +1000, Peter Wang <novalazy at gmail.com> wrote:
> > > My answer would be "no". Just because there is no ambiguity now
> > > does not mean there won't be later. If e.g. a pragma says foo/2,
> > > and the only foo/2 is currently a predicate, then the meaning of the
> > > pragma should not change to apply to func foo/2 as well, when
> > > it is added later. Having a pragma written now apply to code
> > > written in the future would be ... surprising.
> >
> > The compiler would warn about the ambiguity though.
>
> No, it does not. It simply applies the pragma to every pred_info
> with the given name/arity. See do_add_pred_marker in add_pragma.m.
I mean that under my proposal, we would change the compiler to
report ambiguities when and *if* they arise.
>
> > We already have the behaviour that names that were not ambiguous
> > initially may become ambiguous with additional imports, or changes
> > to imported modules.
>
> That is different. Pragmas always apply to the entities defined
> in the current module, so their meaning cannot be affected either
> by changing the set of imported modules, or the contents of imported
> modules.
Ok. I'm just saying if I had written:
:- pragma inline(foo/2).
foo(X, Y) :- ...
which previously compiled fine, then later I added
foo(X, Y) = Z :- ...
and the compiler started telling me I needed to disambiguate
the pragma inline, it would not be surprising at all.
Peter
More information about the developers
mailing list