Trying to understand a closure with unexpected output

Discussion of Common Lisp

Trying to understand a closure with unexpected output

Postby timotheosh » Thu Dec 01, 2016 11:04 am

So, I have been re-brushing my common lisp, and have been wanting to write some AWS api code in the process. Common Lisp has the aws-sign4 package that can be used to sign requests for their API.

The problem I am having is with a closure. aws-sign4 example code fails with the error message "Please bind *aws-credentials* to a function." It is initiated as nil, and the macro in the example is supposedly re-assigining the variable as a function, but it fails (and checking the output, *aws-credentials* is still nil). ... ample.lisp

This code, is what I wrote on my own, and is almost identical to what I think aws-sign4 is suppose to be doing. This code works, and the global *foo* variable gets assigned to a function using a macro:

any insight as to what I am missing, and what helpful comments I might send to the maintainer of aws-sign4 to fix their example?

EDIT: I figured out the problem. It was a namespace conflict. I was not calling the example from the asdf system. I needed to either do that or change the variable in the macro to aws-sign4:*aws-credentials*
Posts: 1
Joined: Thu Feb 18, 2016 1:41 pm

Re: Trying to understand a closure with unexpected output

Postby marcoxa » Sat Dec 17, 2016 11:36 am

It depends on the definition of *AWS-CREDENTIALS*. Was it defined as a DEFVAR or a DEFPARAMETER? If not, you should at least add a

Code: Select all
(declare (special *aws-credentials*))

after the LET that binds it and above the code that uses it.


Marco Antoniotti
Posts: 84
Joined: Thu Aug 14, 2008 6:31 pm

Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 3 guests