Berlin Brown | 1 Jan 2006 06:11
Picon
Gravatar

Error with compiled to abcl files

I am running code that works fine when not compiled to an abcl binary
file.  (note: I am doing this through asdf).

But, when I compile the file, it doesnt seem to recognize the lambda
calls.  Everything else seems to work.  Normally, I will get the
error, "Wrong number arguments, even though the arguments are
right..."

For example:

(defun action-listener (action-func)
  (jinterface-implementation
   (jclass *listener*) "actionPerformed"
   (lambda (event)
     (funcall action-func))))

The (lambda (event) ... works fine when not compiled.  But, once I
compile, I get the error:

"Wrong number of arguments for."

What do you think?

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
Peter Graves | 1 Jan 2006 17:45

Re: Error with compiled to abcl files

On Sun, 1 Jan 2006 at 00:11:41 -0500, Berlin Brown wrote:
> I am running code that works fine when not compiled to an abcl binary
> file.  (note: I am doing this through asdf).
>
> But, when I compile the file, it doesnt seem to recognize the lambda
> calls.  Everything else seems to work.  Normally, I will get the
> error, "Wrong number arguments, even though the arguments are
> right..."
>
> For example:
>
> (defun action-listener (action-func)
>   (jinterface-implementation
>    (jclass *listener*) "actionPerformed"
>    (lambda (event)
>      (funcall action-func))))
>
> The (lambda (event) ... works fine when not compiled.  But, once I
> compile, I get the error:
>
> "Wrong number of arguments for."
>
> What do you think?

I think I need more information before I can tell what's going on.

Can you provide a complete test case? (Complete and minimal would be
even better, but I'd settle for just complete.)

-Peter
(Continue reading)

Andras Simon | 1 Jan 2006 17:51
Picon

Re: Error with compiled to abcl files


On Sun, 1 Jan 2006, Berlin Brown wrote:

> I am running code that works fine when not compiled to an abcl binary
> file.  (note: I am doing this through asdf).
>
> But, when I compile the file, it doesnt seem to recognize the lambda
> calls.  Everything else seems to work.  Normally, I will get the
> error, "Wrong number arguments, even though the arguments are
> right..."
>
> For example:
>
> (defun action-listener (action-func)
>  (jinterface-implementation
>   (jclass *listener*) "actionPerformed"
>   (lambda (event)
>     (funcall action-func))))
>
> The (lambda (event) ... works fine when not compiled.  But, once I
> compile, I get the error:
>
> "Wrong number of arguments for."
>
> What do you think?

The reason is that when you compile action-listener, the closures get
compiled, too. You'll get the same error if you dpn't compile
action-listener but replace (lambda (event) .. ) by (compile nil
(lambda (event) .. )), or any other compiled function.
(Continue reading)

Berlin Brown | 1 Jan 2006 17:56
Picon
Gravatar

Re: Error with compiled to abcl files

I dont have a complete test, because I am using ASDF and a bunch of
other libraries:  But here are the steps:  And, the recent post gave
me a solution:

Load the ASDF library

(asdf:operate 'asdf:load-op 'watcher-lib)

..........

FileInWatcherLib.ASD

(defun action-listener (action-func)
  (jinterface-implementation
   (jclass *listener*) "actionPerformed"
   (lambda (event)
     (funcall action-func))))

(defun add-action-listener (*jcomp* *obj* action-func)
  (jcall
  (jmethod *jcomp* "addActionListener" *listener*)
  *obj*
  (action-listener action-func)))

(defun create-button-panel ()
  (let ((main-panel (jnew (jconstructor *jpanel*)))
	(button (create-button "Submit" nil)))
    (add-action-listener *jbutton* button
			 #'(lambda ()
			     (print "Testing Swing Print")))
(Continue reading)

Berlin Brown | 1 Jan 2006 17:57
Picon
Gravatar

Re: Error with compiled to abcl files

That is what I was thinking, but doesnt SBCL or other lisp allow this?

On 1/1/06, Andras Simon <asimon <at> math.bme.hu> wrote:
>
>
> On Sun, 1 Jan 2006, Berlin Brown wrote:
>
> > I am running code that works fine when not compiled to an abcl binary
> > file.  (note: I am doing this through asdf).
> >
> > But, when I compile the file, it doesnt seem to recognize the lambda
> > calls.  Everything else seems to work.  Normally, I will get the
> > error, "Wrong number arguments, even though the arguments are
> > right..."
> >
> > For example:
> >
> > (defun action-listener (action-func)
> >  (jinterface-implementation
> >   (jclass *listener*) "actionPerformed"
> >   (lambda (event)
> >     (funcall action-func))))
> >
> > The (lambda (event) ... works fine when not compiled.  But, once I
> > compile, I get the error:
> >
> > "Wrong number of arguments for."
> >
> > What do you think?
>
(Continue reading)

Andras Simon | 1 Jan 2006 17:59
Picon

Re: Error with compiled to abcl files


On Sun, 1 Jan 2006, Peter Graves wrote:

> On Sun, 1 Jan 2006 at 00:11:41 -0500, Berlin Brown wrote:
>> I am running code that works fine when not compiled to an abcl binary
>> file.  (note: I am doing this through asdf).
>>
>> But, when I compile the file, it doesnt seem to recognize the lambda
>> calls.  Everything else seems to work.  Normally, I will get the
>> error, "Wrong number arguments, even though the arguments are
>> right..."
>>
>> For example:
>>
>> (defun action-listener (action-func)
>>   (jinterface-implementation
>>    (jclass *listener*) "actionPerformed"
>>    (lambda (event)
>>      (funcall action-func))))
>>
>> The (lambda (event) ... works fine when not compiled.  But, once I
>> compile, I get the error:
>>
>> "Wrong number of arguments for."
>>
>> What do you think?
>
> I think I need more information before I can tell what's going on.
>
> Can you provide a complete test case? (Complete and minimal would be
(Continue reading)

Andras Simon | 1 Jan 2006 18:06
Picon

Re: Error with compiled to abcl files


On Sun, 1 Jan 2006, Berlin Brown wrote:

> That is what I was thinking, but doesnt SBCL or other lisp allow this?

Sorry, I lost you here: what do you mean by "this"? I.e., what is it
that other lisps allow?

Andras

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
Peter Graves | 2 Jan 2006 17:11

Re: Error with compiled to abcl files

On Sun, 1 Jan 2006 at 17:59:22 +0100, Andras Simon wrote:
> On Sun, 1 Jan 2006, Peter Graves wrote:
> > Can you provide a complete test case? (Complete and minimal would be
> > even better, but I'd settle for just complete.)
>
> There's one here: 
> http://sourceforge.net/mailarchive/forum.php?thread_id=3653536&forum_id=9737
>
> It's not minimal, but short and almost complete. If you wrap any
> method definition (in the call to java::%jnew-proxy) in (compile nil
> ..), you'll get the "Wrong number of arguments" error.

OK, I'll try to take a look at this later this week.

-Peter

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
Peter Graves | 5 Jan 2006 04:07

Re: Error with compiled to abcl files

On Mon, 2 Jan 2006 at 08:11:08 -0800, Peter Graves wrote:
> On Sun, 1 Jan 2006 at 17:59:22 +0100, Andras Simon wrote:
> > On Sun, 1 Jan 2006, Peter Graves wrote:
> > > Can you provide a complete test case? (Complete and minimal would be
> > > even better, but I'd settle for just complete.)
> >
> > There's one here: 
> > http://sourceforge.net/mailarchive/forum.php?thread_id=3653536&forum_id=9737
> >
> > It's not minimal, but short and almost complete. If you wrap any
> > method definition (in the call to java::%jnew-proxy) in (compile nil
> > ..), you'll get the "Wrong number of arguments" error.
>
> OK, I'll try to take a look at this later this week.

This is now fixed in CVS.

The problem was that LispHandler.invoke() was calling a compiled
function with 8 or fewer (i.e., <= CALL_REGISTERS_MAX) arguments by
passing the arguments in an array. Fixed-arity compiled functions
(other than builtins) expect calls with fewer than CALL_REGISTERS_MAX
arguments to pass the arguments directly. For the gory details, take a
look at evalCall() in Lisp.java.

For now, I've fixed LispHandler.invoke() by simply making it use
evalCall(). This might not be the best approach, performance-wise, but
it has the advantage that I'm certain to notice when evalCall() breaks.

Your original message notes that %JNEW-PROXY is "unexported, because
it"s experimental and because it needs a better syntax". It's
(Continue reading)

Andras Simon | 5 Jan 2006 21:40
Picon

Re: Error with compiled to abcl files


On Wed, 4 Jan 2006, Peter Graves wrote:

> On Mon, 2 Jan 2006 at 08:11:08 -0800, Peter Graves wrote:
>> On Sun, 1 Jan 2006 at 17:59:22 +0100, Andras Simon wrote:
>>> On Sun, 1 Jan 2006, Peter Graves wrote:
>>>> Can you provide a complete test case? (Complete and minimal would be
>>>> even better, but I'd settle for just complete.)
>>>
>>> There's one here:
>>> http://sourceforge.net/mailarchive/forum.php?thread_id=3653536&forum_id=9737
>>>
>>> It's not minimal, but short and almost complete. If you wrap any
>>> method definition (in the call to java::%jnew-proxy) in (compile nil
>>> ..), you'll get the "Wrong number of arguments" error.
>>
>> OK, I'll try to take a look at this later this week.
>
> This is now fixed in CVS.

Thanks!

>
> The problem was that LispHandler.invoke() was calling a compiled
> function with 8 or fewer (i.e., <= CALL_REGISTERS_MAX) arguments by
> passing the arguments in an array. Fixed-arity compiled functions
> (other than builtins) expect calls with fewer than CALL_REGISTERS_MAX
> arguments to pass the arguments directly. For the gory details, take a
> look at evalCall() in Lisp.java.
>
(Continue reading)


Gmane