in reply to Re^3: Unicode infinity
in thread Unicode infinity

π can't be used as a number because it already parses as an identifier (greek letter) and you can already use it as a sub name.

∞ does not, however, and simply emits a syntax error. You can use it as the delimiter for quote constructs, but that only applies after the beginning token of a quote construct. I'm very narrowly talking about changing perl's failure mode when it encounters this character to do something useful, since infinity is really a character that unambiguously indicates a mathematical value that also has an unambiguous floating-point encoding.

I'd be happy to see many more codepoints given language functionality, if they are unambiguous symbols that imply unambiguous scalar values. I can't name any others offhand. (Mathematicians really ought to stop stealing greek letters for things. I mean it's not like they were using mechanical tools with a limited range of symbols when they started this stuff... they could draw anythign they wanted. And, Greek is still an active language! not a dead one like Latin...)

Replies are listed 'Best First'.
Re^5: Unicode infinity
by Anonymous Monk on Jul 02, 2024 at 04:43 UTC
    > π can't be used as a number because

    perl -Mutf8 -le 'use constant π => 3.141;print sqrt π'
    1.77228665852903
    
      Right, but that's using it as an identifier that returns a constant. In the parsing phase, it goes through "we have a word, what does it mean?" We can't define that as part of the language without breaking existing code, or going through a version-guard like with the new keywords in the builtin:: namespace. The infinity character is not a word character and can't be used as the name of a sub or variable or anything. (other than as the delimiter of a qq∞...∞, but my proposal doesn't break that) It also isn't stealing a useful character from someone's language.