【问题标题】:Calling Class allocated slot on class-names in Common Lisp在 Common Lisp 中的类名上调用类分配的插槽
【发布时间】:2020-11-06 08:10:28
【问题描述】:

有没有办法在类的名称而不是实例上调用 :class 分配的插槽?比如:(class-alloc-slot 'name-of-the-class)

【问题讨论】:

    标签: class lisp common-lisp clos meta-object-protocol


    【解决方案1】:

    LispWorks:

    CL-USER 6 > (defclass foo () ((bar :allocation :class :initform :baz)))
    #<STANDARD-CLASS FOO 402005B3CB>
    
    CL-USER 7 > (make-instance 'foo)
    #<FOO 4020240C33>
    
    CL-USER 8 > (class-prototype (find-class 'foo))
    #<FOO 402005EB73>
    
    CL-USER 9 > (slot-value * 'bar)
    :BAZ
    

    将 CLOSER-MOP 用于便携式 MOP 功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-05
      • 1970-01-01
      • 2023-02-01
      • 1970-01-01
      • 2012-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多