Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

¤ cannot be used #1515

Open
triska opened this issue Jun 19, 2022 · 10 comments
Open

¤ cannot be used #1515

triska opened this issue Jun 19, 2022 · 10 comments

Comments

@triska
Copy link
Contributor

triska commented Jun 19, 2022

Currently, I get:

?- X = ¤.
   error(syntax_error(unexpected_char),read_term/3:0).
?- X = '¤'.
   error(syntax_error(invalid_single_quoted_character),read_term/3).
?- X = "¤".
   error(syntax_error(missing_quote),read_term/3:0).

Is there anything special about this character? Why cannot it be used like other symbols/currency characters such as $?

For comparison, I get with GNU Prolog:

| ?- X = '¤'.

X = '¤'

yes
@triska
Copy link
Contributor Author

triska commented Jun 26, 2022

On the other hand, the toplevel reports the character when asked for it in a different way:

?- char_code(C, 164).
   C = '¤'.

This means that such answer substitutions currently cannot be pasted back as queries.

@UWN
Copy link

UWN commented Aug 23, 2022

We need to identify that class of characters which can be written directly with single or double quotes.

non quote char (* 6.4.2.1 *)
   = graphic char (* 6.5.1 *)
   | alphanumeric char (* 6.5.2 *)
   | solo char (* 6.5.3 *)
   | space char (* 6.5.4 *)
   | meta escape sequence (* 6.4.2.1 *)
   | control escape sequence (* 6.4.2.1 *)
   | octal escape sequence (* 6.4.2.1 *)
   | hexadecimal escape sequence (* 6.4.2.1 *) ;

which is what is used to define those characters that can appear in such quoted context. So extended characters (6.5) that look like characters may be added to non quote char but neither to one of those defined above like graphic char or alphanumeric char.

@triska
Copy link
Contributor Author

triska commented Aug 23, 2022

¬ has the same problem (see also #1591):

?- char_code(C, 172).
   C = '¬'.
?- C = '¬'.
   error(syntax_error(invalid_single_quoted_character),read_term/3).

@UWN
Copy link

UWN commented Aug 24, 2022

You can also extend graphic char and alphanumeric char.

It is a possibility to do so. And for alphanumeric chars Scryer already does this. The question here is rather whether or not it makes sense to extend graphic char which may make the source code much less readable and reliable. Libraries like TPTP have refrained from this, and this although it was suggested in related discussions.

The other question is which non-terminals may be extended. In 6.5 graphic char, alphanumeric char, solo char, layout char and meta char are mentioned. From NOTE 2 it becomes evident that also small letter char and capital letter char can be extended separately. So far in the standard there is no character that can be used in a quoted context but not in another context. But here the mentioned non quote char may be a safer choice for extension. This would be also a bit closer to the way other programming languages like C (WG14 N1518) do it.

Things would get even more complex, when also solo char is extended. So some new characters would be graphic and others solo. Sticking to a more conservative extension seems preferable. Such a more conservative extension does not rule out the use of such symbols but requires that quotes are used to make them better visible.

@triska
Copy link
Contributor Author

triska commented Mar 26, 2023

This works perfectly now, thank you a lot!

?- X = ¤.
   X = ¤.

@triska triska closed this as completed Mar 26, 2023
@triska
Copy link
Contributor Author

triska commented Mar 26, 2023

I am reopening this because I think it is expected (#1749 (comment)) that the symbol cannot be part of a letter token:

?- X = ¤a.
   X = ¤a, unexpected.

@triska
Copy link
Contributor Author

triska commented Mar 26, 2023

Now it seems to work really perfectly, thank you a lot!

@triska triska closed this as completed Mar 26, 2023
@hurufu
Copy link
Contributor

hurufu commented Sep 11, 2024

I'm afraid there is a regression on the latest master (v0.9.4-165-g12a61cdf):

?- X = ¤.
   error(syntax_error(unexpected_char),read_term/3:0).
?- 

Also might be the cause of #2547

@bakaq
Copy link
Contributor

bakaq commented Sep 11, 2024

Probably related to #2529 and #2496 too.

@triska
Copy link
Contributor Author

triska commented Oct 24, 2024

I am reopening this issue because the original issue is now present again, for unclear reasons. At the very least, it requires a conscious decision on how to resolve it.

@triska triska reopened this Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants