此 Joker 非彼 Joker,本文将要介绍的 Joker 是一门使用 Go 编写的 Clojure 解释型方言,同时也是一个 Clojure(Script) linter。
Joker 代码示例
1. 在 Clojure 中编写脚本
2. 即时检查 Clojure(Script) 代码
特性
根据文档的说明,Joker 的目标包括:
joker --hashmap-threshold -1 -e "(pprint (read))"Joker 也罗列了两个不关注的目标:
语法对比
| Joker type | Corresponding Go type |
|---|---|
| BigFloat | big.Float (see below) |
| BigInt | big.Int |
| Boolean | bool |
| Char | rune |
| Double | float64 |
| Int | int |
| Keyword | n/a |
| Nil | n/a |
| Ratio | big.Rat |
| Regex | regexp.Regexp |
| String | string |
| Symbol | n/a |
| Time | time.Time |
| Joker type | Corresponding Clojure type |
|---|---|
| ArrayMap | PersistentArrayMap |
| MapSet | PersistentHashSet (or hypothetical PersistentArraySet, depending on which kind of underlying map is used) |
| HashMap | PersistentHashMap |
| List | PersistentList |
| Vector | PersistentVector |
安装
在 macOS 上,安装 Joker 最便捷的方法是使用 Homebrew:
brew install candid82/brew/joker如果使用 Linuxbrew,可以在 Linux 上使用相同的命令。
如果使用 Arch Linux,提供了 AUR 包。
如果使用 Nix,可以用下面的方式安装 Joker
nix-env -i joker
在其他平台上(或者希望手动安装),为对应的平台下载预编译的二进制文件并将其放在 PATH 中。
当然还可以从源代码构建 Joker。
(文/开源中国)