clojure - 查找包含表单的顶级表单的宏
问题描述
有没有办法使用宏访问顶级表单?大意是:
(defmacro which-defn []
....)
(defn hello []
(which-defn))
(defn world []
(which-defn))
(hello) => 'hello
(world) => 'world
解决方案
(ns tst.demo.core
(:use tupelo.core tupelo.test)
(:require [tupelo.misc :as misc]))
(defn hello []
(misc/fn-info))
(dotest
(is= (hello)
{:class-name "tst.demo.core$hello",
:file-name "core.clj",
:method-name "invokeStatic",
:line-num 6,
:ns-name "tst.demo.core",
:fn-name "hello"}))
推荐阅读
- scala - 二叉树集 - 递归联合
- tensorflow - Keras R GPU 配置使用 Intel 专用 GPU,而不是 NVIDIA 卡
- python - 如何部署在 Django 应用程序下工作的 Python 脚本?
- javascript - 如何正确设置本地主机以显示 p5.js 画布
- sql - Postgresql 错误查询没有结果数据的目的地
- python - 如何在视图中总结 Django 日期范围结果的结果
- javascript - QML:如何在不截断字符的情况下截断字符串?
- django - 在 Django 中,whitenoise 不显示静态文件?
- angular - 延迟加载的路由适用于 routerLink 但不适用于 router.navigate
- python - 如何在python中生成至少小数点后20位的种子随机浮点数?