是否可以在 Crystal 编译时在宏中获取 CharLiteral 的代码点?

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

在Crystal运行时,这是可能的:'?'.ord

Crystal 宏是否有类似的东西?:{% 'a' %}

(我没有有效的用例。这只是出于深奥的原因。)

不,这目前是不可能的。

Here is the documentation 关于您可以在 CharLiteral.

上做什么