Closed wrhall closed 2 years ago
Andy notes that for something like %c{x}
, you're burning a unary operator, %
without a great reason. And you could just write it as char("x")
Purely going with gut feelings here, I like !'x'
the best. The leading !
makes the parse unambiguous, allowing us to reuse '
without losing it's meaning for function calls.
I don't see significant value in supporting array versions, given that "abc" is already a slice of characters.
Why add single quotes at all? The !x
syntax was strange at first but I've gotten used to it. The only major issue is !
IMO, but that's not too different from other languages that have \
syntax for escaped spaces.
Discussing with Andy, the existing syntax is
!c
for the character literal'c'
(if this were C++). (seen in live code in https://github.com/perimosocordiae/advent-of-code/blob/9de86a79aeb5213539dd71647ab0c6abc51db13f/advent2021/day06.ic#L12)Some possible alternatives:
!x
(current)!'x'
|x
|x|
,| |
(space char, i.e.' '
)\
x``%c{x}
"a"[0]
"a"'as_char
oras_char("a")
(as_char or to_char)to_char_array("abc")