Raku / problem-solving

🦋 Problem Solving, a repo for handling problems that require review, deliberation and possibly debate
Artistic License 2.0
70 stars 16 forks source link

Feature Request: recognize "doubled" Unicode characters in Raku ternary operator (question mark and exclamation point). #433

Open jubilatious1 opened 2 months ago

jubilatious1 commented 2 months ago

Unicode provides two characters that can (in combination) be used for Raku's ternary operator:

⁇ DOUBLE QUESTION MARK Unicode: U+2047, UTF-8: E2 81 87

‼️ red double exclamation mark Unicode: U+203C U+FE0F, UTF-8: E2 80 BC EF B8 8F

ATM, ASCII question marks work but Unicode double-question marks do not:

[0] > 1 == 1 ?? True !! False
True
[1] > 1 == 1 ⁇ True !! False
===SORRY!=== Error while compiling:
Confused
------> 1 == 1⏏ ⁇ True !! False
    expecting any of:
        infix
        infix stopper
        statement end
        statement modifier
        statement modifier loop

Same is true for Unicode double-exclamation points:

[2] > 1 == 1 ?? True ‼️ False
===SORRY!=== Error while compiling:
Confused: Found ?? but no !!
------> 1 == 1 ?? True⏏ ‼️ False
    expecting any of:
        infix
        infix stopper

Anyway, I think 1 == 1 ⁇ True ‼️ False looks really cool.

(...and will look even cooler if we can get the Unicode people to accept a GREEN double-question mark).

lizmat commented 2 months ago

I wouldn't mind for consistency, but would be very against using colors. Syntax highlighting should be enough: so if you want ‼️, then adjust your syntax highlighting accordingly, I'd say.

jubilatious1 commented 2 months ago

Hi Liz,

You are quite correct. Initially (above), I wasn't able to locate an uncolored !! Unicode symbol. Only red.

But revisiting the table, I found this one:

‼︎
DOUBLE EXCLAMATION MARK
Unicode: U+203C U+FE0E, UTF-8: E2 80 BC EF B8 8E

Cheers and thank you!

lizmat commented 2 months ago

I always use un in these cases:

% un ‼️
 203C DOUBLE EXCLAMATION MARK ‼
 FE0F VARIATION SELECTOR-16 ️

\

FCO commented 2 months ago

https://github.com/rakudo/rakudo/pull/1029

lizmat commented 2 months ago

It's unclear to me why this got reverted and why? Some simple code spelunking didn't give me an answer :-(

FCO commented 2 months ago

I don't remember either (if I ever understood)