簡體   English   中英

使用 `raise' function 要求 `hy' 宏會在 `require' 上觸發 `raise'

[英]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 unlessNameError不存在時並沒有觸發它,因為它在一年前從hy核心轉移到了hyrule

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM