明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1169|回复: 2

[经验] 函数名 SUBR 转 SYM

[复制链接]
发表于 2013-12-28 15:51 | 显示全部楼层 |阅读模式
  1. (defun mymul (a b) (* a b))
  2. ;;函数j1
  3. (defun j1 (funname arglist)
  4.   (if (or (= (type funname) 'SUBR) (= (type funname) 'USUBR))
  5.     (setq funname 'funname)
  6.   )
  7.   (apply funname arglist)
  8. )
  9. ;;函数j2
  10. (defun j2 (funname arglist / temp)
  11.   (if (or (= (type funname) 'SUBR) (= (type funname) 'USUBR))
  12.     (progn (setq temp funname) ;
  13.            (setq funname 'temp)
  14.            ;;(setq funname (function temp))
  15.     )
  16.   )
  17.   (apply funname arglist)
  18. )
运行结果如下:
$ (mymul 2 3)
6
_$ (j1 'mymul '(2 3))
6
_$ (j1 mymul '(2 3))
; 错误: 函数错误: FUNNAME

_$ (j2 mymul '(2 3))
6

函数名数据类型 SUBR 一般用quote或function可以转成SYM
但是调用函数过程中需要变量才能达到目的
发表于 2013-12-28 16:01 | 显示全部楼层
这样写呢?
  1. (defun j1 (funname arglist)
  2.   (and (or (= (type funname) 'SUBR) (= (type funname) 'USUBR))
  3.        (apply funname arglist)
  4.   )
  5. )
 楼主| 发表于 2013-12-28 16:18 | 显示全部楼层
自贡黄明儒 发表于 2013-12-28 16:01
这样写呢?

; 错误: 函数错误: #<USUBR @09c5fc80 MYMUL>
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-17 17:51 , Processed in 0.182396 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表