Re: [m-users.] Compiler bug found

"Richard O'Keefe" <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <CABcYAdKRzFLcRt6acE+_MQfJxbnepUbYFOwBHsJaAfi2m0FkLA@mail.gmail.com>
Mercury's treatment of variables beginning with underscore
follows Prolog closely.
"_" all by itself is a "wild card" with each occurrence
standing for a different variable.
A variable that does not begin with underscore is expected
to occur at least twice and a 'singleton variable' warning
will be issued if this is not so.
A variable (other than the wild card) that begins with an
underscore is expected to occur exactly once and a warning
will be issued if such a variable is repeated.

Historically it was important to be able to begin
a variable with an underscore to mark it as a variable
if you were using a terminal with a single case of
letters.  Code like
+append(_X, [_X,.._]).
+append(_X, [_,.._L])-append(_X, _L).
was not unusual.  To this day, if you are writing in a
script that does not make a case distinction (such as
Chinese or Japanese) you need to be able to prefix a
word in your language with an underscore to make it a
variable WITHOUT turning it into a wildcard.


On Fri, 24 Feb 2023 at 07:19, Volker Wysk <[email protected]> wrote:

> Am Freitag, dem 24.02.2023 um 02:15 +1100 schrieb Zoltan Somogyi:
> > A variable token consisting of single underscore is treated specially:
> > each instance of @samp{_} denotes a distinct variable.
> >
> > It does NOT say that *every* variable that starts with an underscore
> denotes
> > a distinct variable.
>
> Hmm... I thought it does. Maybe it's like that in Prolog.
>
> Cheers,
> Volker
> _______________________________________________
> users mailing list
> [email protected]
> https://lists.mercurylang.org/listinfo/users
>

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.