[英]Requiring `hy' macro with `raise' function triggers `raise' on `require'
當試圖在另一個文件中require
以下宏時, raise
似乎會立即觸發:
(defmacro assert [a [b True] [message None]]
`(unless (= ~a ~b) (raise (AssertionError (or ~message ~a)))))
這會導致AssertionError: True
。
重現步驟(有時有效,有時無效):
echo '(defmacro assert [a [b True] [message None]] `(unless (= ~a ~b) (raise (AssertionError (or ~message ~a)))))' > a.hy
echo '(require a [assert])' > b.hy
echo '(assert True)' >> b.hy
hy b.hy
In another instance of Python evaluating function arguments before names, as stated by Kodiologist in their comment here and their answer on one of my previous questions "Non-existent hy macros runs assertions, but fails appropriately with everything else" , the issue was that unless
當NameError
不存在時並沒有觸發它,因為它在一年前從hy
核心轉移到了hyrule
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.