This is the mail archive of the guile-emacs@sourceware.cygnus.com mailing list for the Guile project.


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

Re: import-lisp-macro


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> Yes, we can do that by defining this:
> 
>   (import-lisp-function buffer-substring buffer-substring-lispref)
> 
>   (define (buffer-substring . args)
>     ((apply buffer-substring-lispref args)))

Of course, we could add a new macro that does this automatically:

  (define-macro (import-lisp-function-by-value func . rest)
    (if (null? (lispref->scm (lisp-apply 'functionp (list func))))
        (lisp-apply 'error (list "No such function: %s" func)))
    (let ((name (if (pair? rest) (car rest) func)))
      `(define (,name . args)
         (lispref->scm (lisp-apply ',func args)))))
  (export import-lisp-function-by-value)

  (import-lisp-function-by-value buffer-substring)

This works in the previous manner.  I guess all functions that
return a number, symbol, or string may be imported by using this.

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