在线程宏中使用 get

Use get in threading macro

以下三个示例失败并出现以下错误:

(setv dct {1 2 3 4})
(setv dcts "dct")

;; (print (get (. (globals) [dcts]) 1))
(print (-> (globals) (. [dcts]) (get 1)))

;; (print (get (get (globals) "dct") 1))
(print (-> (globals) (get "dct") (get 1)))

;; (print (get (get (globals) dcts) 1))
(print (-> (globals) (get dcts) (get 1)))
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 267, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "/home/shadowrylander/test.hy", line 5
    (print (-> (globals) (. [dcts]) (get 1)))
                                         ^
hy.errors.HySyntaxError: parse error for pattern macro 'get': got unexpected end of file, expected: some(...)
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 267, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "/home/shadowrylander/test.hy", line 8
    (print (-> (globals) (get "dct") (get 1)))
                              ^
hy.errors.HySyntaxError: parse error for pattern macro 'get': got unexpected end of file, expected: some(...)
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 267, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "/home/shadowrylander/test.hy", line 11
    (print (-> (globals) (get dcts) (get 1)))
                              ^
hy.errors.HySyntaxError: parse error for pattern macro 'get': got unexpected end of file, expected: some(...)

是否无法将 get 或一般宏与线程宏 (->) 一起使用?我已经多次重写打印语句以确保括号一致,它们都在那里。

以下是我在 Hy master 上的作品。你忘了require吗?

=> (require hyrule [->])
=> (setv dct {1 2 3 4})
=> (setv dcts "dct")
=> (print (-> (globals) (get dcts) (get 1)))
2
=> (require hyrule [->])

(setv dct {1 2 3 4})
(setv dcts "dct")

;; (print (get (. (globals) [dcts]) 1))
(print (-> (globals) (. [dcts]) (get 1)))

;; (print (get (get (globals) "dct") 1))
(print (-> (globals) (get "dct") (get 1)))

;; (print (get (get (globals) dcts) 1))
(print (-> (globals) (get dcts) (get 1)))