0

Basically I tried evaluating the function below but keep getting the following error:

 WARNING :
MAINDIA is neither declared nor bound,
it will be treated as if it were declared SPECIAL.
WARNING :
SOUT is neither declared nor bound,
it will be treated as if it were declared SPECIAL.
WARNING :
NORT is neither declared nor bound,
it will be treated as if it were declared SPECIAL.
*** - NIL: variable MAINDIA has no value
The following restarts are available:
ABORT          :R1      Abort debug loop
ABORT          :R2      Abort debug loop
ABORT          :R3      Abort debug loop
ABORT          :R4      Abort debug loop
ABORT          :R5      Abort debug loop
ABORT          :R6      Abort debug loop
ABORT          :R7      Abort debug loop
ABORT          :R8      Abort main loop

When I tried copy and paste an example from the internet it works, but when I manually type it into the interpreter it doesn't work. Also, I am running CLISP from emacs.

Code:

(defun diagonal-mast (sq)
  (let* ((maindia #x8040201008040201)
         (diag (- (* 8 (logand sq 7))
                  (logand sq 56)))
         (nort (logand (- diag)
                       (ash diag -31)))
         (sout (logand diag (ash (- diag) -31))))
    (ash (ash maindia (- sout))
         nort)))

NOte: I am on CLISP 2.48

11
  • Try let, rather than let* - you are not using the definitions in each other. Commented Jan 12, 2012 at 15:48
  • 1
    @Marcin you're wrong, he's indeed using them. Anyway, this code is perfectly valid and works well in SBCL. Check what's the value of let* (could it be, that you've redefined it somewhere?) Commented Jan 12, 2012 at 16:24
  • @VsevolodDyomkin: Only diag, but yes - it should be valid, which is why I suggested trying let. Commented Jan 12, 2012 at 16:26
  • 1
    no errors returned in sbcl 1.0.55. Commented Jan 12, 2012 at 17:16
  • 3
    Works fine in both CLISP 2.49 and SBCL 1.0.53 here. If it works when you copy-and-paste but not when you type it in, then (assuming you're not making any typos) it sounds like a terminal/emacs problem, not a code problem. Are you using SLIME? Commented Jan 12, 2012 at 23:20

1 Answer 1

1

In all likelihood, your problem is with emacs, not with the code, because it's running fine in the commenters' and my lisps. I'm not on emacs anymore, so it's possible the following solution is deprecated or entirely false, but if you start Emacs via emacs --debug-init and get an error message, you've got some setup issue rather than a code issue. Elsewise, it seems like your lisp implementation is the problem, not your lisp writing. If it's somehow your lisp implementation, just rebuild and it should be fine. If it's your setup, i'm pretty sure slimedev has some a pretty exhaustive list of bugs and fixes. Good hunting.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.