|From:||Panicz Maciej Godek|
|Subject:||Re: Add support for record types in GOOPS methods?|
|Date:||Tue, 21 Oct 2014 17:37:53 +0200|
Last night, I encountered what I consider to be a frustrating limitation
of GOOPS methods: They do not support record type descriptors, only
classes. This makes it difficult to take advantage of generic
procedures without also buying into the rest of the GOOPS system.
Here's some code that I wish would work:
(define-method (foobar (foo <foo>))
The error thrown by `define-method' is:
ERROR: In procedure class-direct-methods:
ERROR: In procedure slot-ref: Wrong type argument in position 1 (expecting instance): #<record-type <foo>>
There is an ugly workaround. You can use `class-of' on an instance of a
record type to get a class in return.
This code works, but is unideal:
(define <foo-class> (class-of (make-foo #f)))
(define-method (foobar (foo <foo-class>))
I don't know very much about GOOPS, so I am seeking help. Would it make
sense for `define-method' to work the way I want? If so, could anyone
suggest a way to make `define-method' to DTRT for record types? Perhaps
it could auto-generate and cache the class from the record type
descriptor, but I'm not sure how since the current workaround requires
an instance of that record.
|[Prev in Thread]||Current Thread||[Next in Thread]|