forked from alex-eg/sex
spell ? and ! in names as letters C takes
A Lisp predicate came out as ident_start?, which no C compiler reads. ʔ and ꜝ are letters that look the part; ǃ looks closer, but clang flags it as a homoglyph of `!' at every use. Fixes #49.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(input)
|
||||
(output "café 日本語 🍺" "café1" "naïve: 3")
|
||||
(output "café 日本語 🍺" "café1" "naïve: 3" "predicate: 1 0")
|
||||
(return 0)
|
||||
|
||||
;;; Non-ASCII string literals and identifiers.
|
||||
@@ -13,12 +13,22 @@
|
||||
;;; non-ASCII characters must survive unkebabify intact -- getting this
|
||||
;;; wrong truncates the name silently, and the program still compiles
|
||||
;;; and runs, just under a different name than the one written.
|
||||
;;;
|
||||
;;; `?' and `!' end Lisp predicates and mutators, and C takes neither:
|
||||
;;; they become the letters ʔ and ꜝ.
|
||||
|
||||
(include stdio.h)
|
||||
|
||||
(fn zero? ((n int)) bool (return (== n 0)))
|
||||
(fn clear! ((n (* int))) void (= (* n) 0))
|
||||
|
||||
(pub fn main () int
|
||||
(puts "café 日本語 🍺")
|
||||
(puts "café1")
|
||||
(var naïve-count int 3)
|
||||
(printf "naïve: %d\n" naïve-count)
|
||||
(var n int 5)
|
||||
(var before bool (zero? n))
|
||||
(clear! (& n))
|
||||
(printf "predicate: %d %d\n" (zero? n) before)
|
||||
(return 0))
|
||||
|
||||
Reference in New Issue
Block a user