[m-users.] Any way to write . or : as a character literal?

Richard O'Keefe raoknz at gmail.com
Mon Dec 7 00:45:55 AEDT 2020


For the sake of historical accuracy,
character literals in Edinburgh Prolog had the form
 0'<char>
and were integers.
Nor were parentheses always required for atoms, e.g.,
?- X = ., Y = :, Z = + .
X =  ('.'),
Y =  (:),
Z =  (+).

The ISO standard broke a lot of things.


On Sun, 6 Dec 2020 at 17:12, Zoltan Somogyi <zoltan.somogyi at runbox.com>
wrote:

>
>
> On Sat, 5 Dec 2020 22:51:52 -0500, "Jeremy W. Sherman" <
> jeremyw.sherman at gmail.com> wrote:
> > Since character literals are the same as single-character quoted
> > names, is there any way to escape or write either of these outside of
> > a circumlocution like `det_from_int(0':)`?
>
> Yes, there is:
>
>     Char = ('.')
>
> Basically, if a character is an operator, you need to put parentheses
> around them, even if you have already put single quotes around them.
> Basically, if x is an operator, then the scanner/parser consider 'x' to be
> an operator as well. The parentheses say there is nothing to apply
> the operator to.
>
> I just checked: it seems the language reference manual does not
> explicitly talk about the need for parentheses in such cases. I will fix
> that.
>
> The need for () is an unfortunate side effect of reusing the syntax rules
> of Prolog
> for Mercury. That decision is a lot less useful now than it was when
> Mercury was just starting out, but its less-than-nice effects are not
> important
> enough to fix with a backward-compatibility-breaking change. The Mercury
> community is small enough; we don't want to break it in half, as Python 3
> did
> for its community.
>
> Zoltan.
> _______________________________________________
> 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/20201207/303ad05d/attachment-0001.html>


More information about the users mailing list