This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: procedure-name-symbol to procedure


Did you try to use hygienic macroses? Or you want to use just only "eval" function for this situation?

02.03.2013, 15:18, "Chuah Teong Leong" <teongleong@gmail.com>:
> Hi, is it possible to construct a symbol and retrieve the procedure
> from the interactive environment associated the symbol name?
>
> I have the following code
> ;;  (if (w-key-event? e)
> ;;      (begin
> ;;        (set! last-key 'w)
> ;;        (register-key-down 'w)
> ;;        ))
> ;;  (if (a-key-event? e)
> ;;      (begin
> ;;        (set! last-key 'a)
> ;;        (register-key-down 'a)
> ;;        ))
> ;;  (if (s-key-event? e)
> ;;      (begin
> ;;        (set! last-key 's)
> ;;        (register-key-down 's)
> ;;        ))
> ;;  (if (d-key-event? e)
> ;;      (begin
> ;;        (set! last-key 'd)
> ;;        (register-key-down 'd)
> ;;        ))
>
> and I'm probably going to do the same for every key I care about.
>
> I however would like to do shorten the code to look like this
>
> (vector-map
>          (lambda (key-sym)
>                 (define proc-sym
>                   (string->symbol
>                    (string-append (symbol->string key-sym) "-key-event?")))
>
>                 (if (eval (list proc-sym 'e))
>                     (begin
>                       (set! last-key 'key-sym)
>                       (register-key-down 'key-sym)
>                       ))
>                 ) supported-keys))
>
> (define supported-keys (vector 'w 'a 's 'd ))
>
> This did not work because it couldn't find w-key-down? and the other procedures.

-- 
Alex Moiseenko


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]