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

[plt-scheme] dynamic method-name for send, in v200

Hi all,

In the send syntax with v200 (I'm using alpha 12), is it possible to 
have the method-name dynamically created?


(require (lib "class.ss"))
(define tester%
   (class object%
     (define-values (x y) (values 0 0))
     (define (set-x! val) (set! x val))
     (define (set-y! val) (set! y val))
     (public set-x! set-y!)
     (super-instantiate ())))

(let ((o (make-object tester%))
       (do-x? #t))
   (send o (if do-x? set-x! set-y!) 10))

            causes a compiler complaint (method name is not an identifier)

The example should make it clear the functionality I wish to achieve. 
I get the same problem if I try send* or with-method.

The application for this is that I'm storing lists of methods for a 
number of classes within a hash table; I want to be able to retrieve 
the methods from the hash table and then apply them to the object 
using the send syntax.  At present, I'm creating separate methods for 
each option, as follows:

(define (set-x! obj val) (send obj set-x! val))

This works, but requires a lot of extra typing.

	thanks for any help,


Dr. Peter Lane
ESRC Centre for Research in Development,
Instruction and Training (CREDIT)
School of Psychology, University of Nottingham

Email: pcl@psychology.nottingham.ac.uk
Tel:   + 44 (0) 115 951 5310
Fax:   + 44 (0) 115 951 5324
URL:   http://www.psychology.nottingham.ac.uk/staff/Peter.Lane