Replace hyify
with unmangle
This commit is contained in:
parent
3c97d2982c
commit
6875ae0e3f
@ -454,20 +454,16 @@ as EOF (defaults to an empty string)."
|
|||||||
"Reads and tokenizes first line of `input`."
|
"Reads and tokenizes first line of `input`."
|
||||||
(read :from-file (StringIO input)))
|
(read :from-file (StringIO input)))
|
||||||
|
|
||||||
(defn hyify [text]
|
|
||||||
"Convert `text` to match hy identifier."
|
|
||||||
(.replace (string text) "_" "-"))
|
|
||||||
|
|
||||||
(defn keyword [value]
|
(defn keyword [value]
|
||||||
"Create a keyword from `value`.
|
"Create a keyword from `value`.
|
||||||
|
|
||||||
Strings numbers and even objects with the __name__ magic will work."
|
Strings numbers and even objects with the __name__ magic will work."
|
||||||
(if (and (string? value) (value.startswith HyKeyword.PREFIX))
|
(if (and (string? value) (value.startswith HyKeyword.PREFIX))
|
||||||
(hyify value)
|
(unmangle value)
|
||||||
(if (string? value)
|
(if (string? value)
|
||||||
(HyKeyword (+ ":" (hyify value)))
|
(HyKeyword (+ ":" (unmangle value)))
|
||||||
(try
|
(try
|
||||||
(hyify (.__name__ value))
|
(unmangle (.__name__ value))
|
||||||
(except [] (HyKeyword (+ ":" (string value))))))))
|
(except [] (HyKeyword (+ ":" (string value))))))))
|
||||||
|
|
||||||
(defn name [value]
|
(defn name [value]
|
||||||
@ -476,11 +472,11 @@ Strings numbers and even objects with the __name__ magic will work."
|
|||||||
Keyword special character will be stripped. String will be used as is.
|
Keyword special character will be stripped. String will be used as is.
|
||||||
Even objects with the __name__ magic will work."
|
Even objects with the __name__ magic will work."
|
||||||
(if (and (string? value) (value.startswith HyKeyword.PREFIX))
|
(if (and (string? value) (value.startswith HyKeyword.PREFIX))
|
||||||
(hyify (cut value 2))
|
(unmangle (cut value 2))
|
||||||
(if (string? value)
|
(if (string? value)
|
||||||
(hyify value)
|
(unmangle value)
|
||||||
(try
|
(try
|
||||||
(hyify (. value __name__))
|
(unmangle (. value __name__))
|
||||||
(except [] (string value))))))
|
(except [] (string value))))))
|
||||||
|
|
||||||
(defn xor [a b]
|
(defn xor [a b]
|
||||||
|
Loading…
Reference in New Issue
Block a user