Discussion:
[Lisp-cn] [CL]有没有办法像定义结构的显示方式一样定义对象的显示方式?
宋为@凉拌茶叶
2014-08-13 02:40:42 UTC
Permalink
《ANSI Common Lisp》在介绍结构的时候有这么一段例子:
(defstruct (point (:conc-name p)
(:print-function print-point))
(x 0)
(y 0))
(defun print-point (p stream depth)
(format stream "#<~A, ~A>" (px p) (py p)))
这样可以定义 point 结构的显示方式,那么有没有类似的办法来定义对象的显
示方式呢?
--
--
Lisp-cn(Lisp中文用户组)
CLUG http://lisp.org.cn

---
您收到此邮件是因为您订阅了 Google 网上论坛的“Lisp-cn(Lisp中文用户组)”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到lisp-cn+***@googlegroups.com。
要查看更多选项,��
宋为@凉拌茶叶
2014-08-13 02:49:10 UTC
Permalink
Oops,才发现栈爆网上面有
|(defclass foo()
((name:accessor foo-name)))|
|(defmethod print-object((obj foo) out)
(print-unreadable-object(obj out:typet)
(format out"~s" (foo-name obj))))|
《ANSI Common Lisp》在介绍结构的时候有这么一段例子:
(defstruct (point (:conc-name p)
(:print-function print-point))
(x 0)
(y 0))
(defun print-point (p stream depth)
(format stream "#<~A, ~A>" (px p) (py p)))
这样可以定义 point 结构的显示方式,那么有没有类似的办法来定义对象的显
示方式呢?
--
--
Lisp-cn(Lisp中文用户组)
CLUG http://lisp.org.cn

---
您收到此邮件是因为您订阅了 Google 网上论坛的“Lisp-cn(Lisp中文用户组)”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到lisp-cn+***@googlegroups.com。
要查看更多选项,请访问 https://groups.google.com
Loading...