Elisp获取功能? [英] Elisp get function arity?

查看:132
本文介绍了Elisp获取功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做:

(function-arity (intern "expt"))

我googled了这个解决方案
https://github.com/emacsmirror/parser/blob/master/parser-fn.el

I googled up this solution https://github.com/emacsmirror/parser/blob/master/parser-fn.el

但是它使用 help-function-arglist ,所以这并不直接。
我想要一些更坚实的东西,最好是坚固的。

But it's using help-function-arglist, so it's not exactly straightforward. I'd like something more solid, preferably rock-solid.

推荐答案

实体 function-arity 。在大多数人们想要的情况下,他们真正想要的是根据接受的参数多少来调用函数(因为它的签名在不同的Emacs版本中是不同的),在这种情况下,try称之为许多争议,并抓住潜在的错误就像获得的一样好。

There's no such thing as a rock-solid function-arity. In most cases where people want it, what they really want is to call a function in different ways depending on how many arguments it accepts (because its signature is different in different Emacs versions, for example), in which case the approach of "try calling it with many arguments and catch the potential error" is about as good as it gets.

这篇关于Elisp获取功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆