On 8/18/05, Ed Watkeys <[EMAIL PROTECTED]> wrote: > Hi, > > I'm writing a program where I'd like to instantiate a Meroon object by > class name. Based on what I know about Meroon, it seems like the easiest > way is to to something like this: > > (define (instantiate-object-by-class-name name) > (let ((make-instance > (eval (string->symbol > (string-append > "make-" > (symbol->string name)))))) > (make-instance))) > > BUT make-instance requires that all fields be initialized, so this proc > will only work with class with no fields. What I'd really like is a way to > use the instantiate macro but specify a computed class name. A little > macro magic could take care of that problem, but is there a better (more > Meroonic?) way to do what I'm looking for? >
>From a quick look at the Meroon sources: (->Class SYMBOL) gives you the class with the given name, and (make-maker CLASS) returns a constructor procedure (which must have the proper arity for all initialiizers). I have no elegant solution right now, but one way might be to use (Class-fields CLASS) to access the fields and figure out what arguments are needed (see also `check-conformity' in maker.scm). cheers, felix _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
