[cffi-devel] defcallback ignores ignorable <g>
Whoa, CFFI rocks, having a lot of fun creating an FFI-based version of Celtk. As the subject suggests, methinks the defcallback macro knows about IGNORE but not IGNORABLE. I use the latter a lot because of debug statements that come and go. best, kenny
On 2006-maj-13, at 23:56, Ken Tilton wrote:
As the subject suggests, methinks the defcallback macro knows about IGNORE but not IGNORABLE. I use the latter a lot because of debug statements that come and go.
Hmm, we're putting the declarations in the wrong place. (defcallback foo :int ((a :int) (b :int)) (declare (ignorable b)) a) Macroexpands into something like: (FOREIGN-FUNCTIONS:DEFUN-FOREIGN-CALLABLE CFFI-CALLBACKS::|CFFI::FOO| ((A :INT) (B :INT)) (DECLARE (:CONVENTION :C)) (DECLARE (IGNORABLE B)) (LET ((A (VALUES A))) (LET ((B (VALUES B))) ;; Allegro will warn here because this new B is unused. ;; ;; Perhaps the declarations should go here? ;; (except for IGNORE declarations and maybe others?) (BLOCK FOO A)))) -- Luís Oliveira http://student.dei.uc.pt/~lmoliv/
On 5/13/06, Luís Oliveira <luismbo@gmail.com> wrote:
On 2006-maj-13, at 23:56, Ken Tilton wrote:
As the subject suggests, methinks the defcallback macro knows about IGNORE but not IGNORABLE. I use the latter a lot because of debug statements that come and go.
Hmm, we're putting the declarations in the wrong place.
That is just blind bad luck. I looked at the code and I was not joking when I said it ignores IGNORABLE: (defun collect-ignored-args (declarations) (loop for declaration in declarations append (loop for decl in (cdr declaration) when (eq (car decl) 'cl:ignore) append (cdr decl)))) Note that (declare (ignore)) works fine, so I think (declare (ignorable)) will go in the right place if it is not ignored. By the macro. <g> kt
On 2006-maj-14, at 03:45, Luís Oliveira wrote:
Hmm, we're putting the declarations in the wrong place.
Ok, assuming that placing the declarations /after/ the translations take place is the right thing to do, I have a fix for this. All that poking at the declarations to figure out ignored arguments is unnecessary now though. It only works as a (silly?) optimization right now: arguments declared ignored won't have their (possibly expensive) translations applied. Since the user could avoid the (possibly expensive) translation by simply using a primitive type instead, does anyone think this optimization is worthwhile or should we remove the respective ~20 lines of code from src/functions.lisp? -- Luís Oliveira http://student.dei.uc.pt/~lmoliv/
Luís Oliveira <luismbo@gmail.com> writes:
Since the user could avoid the (possibly expensive) translation by simply using a primitive type instead, does anyone think this optimization is worthwhile or should we remove the respective ~20 lines of code from src/functions.lisp?
I would be in favor of removing this optimization. James
participants (3)
-
James Bielman
-
Ken Tilton
-
Luís Oliveira