<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">For the sake of historical accuracy,</div><div class="gmail_default" style="font-family:monospace,monospace">character literals in Edinburgh Prolog had the form<br></div><div class="gmail_default" style="font-family:monospace,monospace"> 0'<char></div><div class="gmail_default" style="font-family:monospace,monospace">and were integers.</div><div class="gmail_default" style="font-family:monospace,monospace">Nor were parentheses always required for atoms, e.g.,</div><div class="gmail_default" style="font-family:monospace,monospace">?- X = ., Y = :, Z = + .<br>X = ('.'),<br>Y = (:),<br>Z = (+).<br><br></div><div class="gmail_default" style="font-family:monospace,monospace">The ISO standard broke a lot of things.<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 6 Dec 2020 at 17:12, Zoltan Somogyi <<a href="mailto:zoltan.somogyi@runbox.com">zoltan.somogyi@runbox.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On Sat, 5 Dec 2020 22:51:52 -0500, "Jeremy W. Sherman" <<a href="mailto:jeremyw.sherman@gmail.com" target="_blank">jeremyw.sherman@gmail.com</a>> wrote:<br>
> Since character literals are the same as single-character quoted<br>
> names, is there any way to escape or write either of these outside of<br>
> a circumlocution like `det_from_int(0':)`?<br>
<br>
Yes, there is:<br>
<br>
Char = ('.')<br>
<br>
Basically, if a character is an operator, you need to put parentheses<br>
around them, even if you have already put single quotes around them.<br>
Basically, if x is an operator, then the scanner/parser consider 'x' to be<br>
an operator as well. The parentheses say there is nothing to apply<br>
the operator to.<br>
<br>
I just checked: it seems the language reference manual does not<br>
explicitly talk about the need for parentheses in such cases. I will fix that.<br>
<br>
The need for () is an unfortunate side effect of reusing the syntax rules of Prolog<br>
for Mercury. That decision is a lot less useful now than it was when<br>
Mercury was just starting out, but its less-than-nice effects are not important<br>
enough to fix with a backward-compatibility-breaking change. The Mercury<br>
community is small enough; we don't want to break it in half, as Python 3 did<br>
for its community.<br>
<br>
Zoltan.<br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.mercurylang.org" target="_blank">users@lists.mercurylang.org</a><br>
<a href="https://lists.mercurylang.org/listinfo/users" rel="noreferrer" target="_blank">https://lists.mercurylang.org/listinfo/users</a><br>
</blockquote></div>