[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessor with 2/3 parameters

From: Neil Jerram
Subject: Re: accessor with 2/3 parameters
Date: Sun, 20 Aug 2006 00:17:48 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Neil Jerram <address@hidden> writes:

> Not that I know of.  I'll take a look at the code though.

Well, the following seems to work ...

(use-modules (oop goops))
(define-method (second (l <list>)) (cadr l))
(define-method (set-second (l <list>) val) (set-car! (cdr l) val))
(define-method (second (l <vector>)) (vector-ref l 1))
(define-method (set-second (l <vector>) val) (vector-set! l 1 val))
(define sec (make-procedure-with-setter second set-second))
(sec '(1 2 3)) => 2
(sec #(1 2 3)) => 2
(define l (list 'a 'b 'c))
(set! (sec l) 'fff)
l => (a fff c)
(define l (vector 'a 'b 'c))
(set! (sec l) 'fff)
l => #(a fff c)

In other words, it appears that the args of make-procedure-with-setter
can be generics.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]