[m-users.] Compiler bug found

Richard O'Keefe raoknz at gmail.com
Fri Feb 24 09:41:47 AEDT 2023


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 <post at volker-wysk.de> 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
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20230224/c93fbb48/attachment-0001.html>


More information about the users mailing list