Search code examples
crystal-lang

Is it possible to get the codepoint of a CharLiteral at the Crystal compile time in a macro?


At the Crystal runtime, this is possible: '?'.ord

Is there anything similar for a Crystal macro?: {% 'a' %}

(I have no valid use case for this. It's just for esoteric reasons.)


Solution

  • No, this is currently not possible.

    Here is the documentation about what you can do on a CharLiteral.