ocaml - 使用 ocaml 属性引发用户定义的编译器警告
问题描述
有没有办法将属性附加到函数定义,以便编译器发出用户定义的警告消息,类似于 [@@deprecated] 所做的。
我想写一些类似的东西
let dangerous_function[@@warn "use this function with caution, are sure ?"] = ...
然后,编译代码
let _ = dangerous_function ...
会发出警告。
解决方案
目前这是不可能的,但这可能会成为OCaml 4.08 中的新功能
val foo: int -> int
[@@ocaml.alert unsafe "Please use bar instead!"]
推荐阅读
- javascript - 如何将 azure b2c 与 react 集成
- c++ - 在 Python3 中将 std::string 转换为 C++ 中的 PyObject
- kubernetes - 我可以从外部文件中获取 configMap 值吗?
- c# - Unity - FPS刚体控制器未与球形重力对齐
- c++ - C++解析器中的Bison %token-table替代品?
- mysql - 如何激活命名时区
- twitter-bootstrap - 引导程序中对块引用的 bg-faded 效果
- c - 为什么 gcc 和 clang 不对库函数的未使用结果发出警告?
- inno-setup - Inno Setup中ComboBox更改后在下一个屏幕上动态显示控件和内容?
- vba - VBA for ms-WORD - 基于对列表在所有单词实例上添加带有 VBA 的语音指南