[m-users.] Why can't there be multiple field constructor field names in the same module?

Peter Wang novalazy at gmail.com
Thu Oct 14 12:55:08 AEDT 2021


On Thu, 14 Oct 2021 12:34:02 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> 
> 2021-10-14 11:55 GMT+11:00 "Philip White" <philip at pswhite.org>:
> > I'm getting an error like "field abc multiply defined" for type
> > definitions like the following:
> > 
> > :- type x ---> x(abc :: int).
> > :- type y ---> y(abc :: int).
> > 
> > The error is quite clear, so I'm not confused what it's complaining
> > about; I'm just confused *why*. Is there a fundamental reason that
> > having fields with the same name in the same module is unacceptable, or
> > has no one yet implemented support for it?
> 

The requirement for field names to be unique within a module was lifted
as of ROTD 2021-05-07 or so.

However, it is still not allowed to declare field getter/setter
functions for multiple fields of the same name in the same module, e.g.

    :- func abc(x) = int.
    :- func abc(y) = int.

Peter


More information about the users mailing list