Trying to understand a closure with unexpected output

Discussion of Common Lisp
Post Reply
timotheosh
Posts: 1
Joined: Thu Feb 18, 2016 1:41 pm

Trying to understand a closure with unexpected output

Post by 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).
https://github.com/copyleft/aws-sign4/b ... 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: http://pastebin.com/ipzQHfj8

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*

marcoxa
Posts: 85
Joined: Thu Aug 14, 2008 6:31 pm

Re: Trying to understand a closure with unexpected output

Post by 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.

Cheers

Marco
Marco Antoniotti

Post Reply