Pedro Costa
Pedro Costa

Reputation: 437

Return in lisp error

So i have this line of code as part of a function and it recieves the "no" as an argument.

(cond ( (avaliar-no (no-tabuleiro no)) (return no)))

The problem is when i do the (return no) i get this error :

Unknown block NIL in form
#S(COMPILER::MULTIPLE-TRANSFORMS-RECORD :FORMS (#
#) :ORIGINAL-PATH 3946)

Anyone know what this might be ?

Heres the whole function (its not finished yet)

(defun minimax (no estado)

(let ( (sucessores nil) (v nil))
  ;se o no for solucao entao retornamos esse nó e guardamos o seu custo na lista
  (cond ( (avaliar-no (no-tabuleiro no)) (return no)) ;falta fazer o (setf *valoresF* valorDoNo)
  ;se nao for solucao entao expandimo o nó
  (t(setf sucessores (no-sucessores no estado))))
  ;se o estado for min entao metemos o V a +oo e corremos o algoritmo para toda a lista de sucessores
  ;(cond ( (and(>= (length sucessores)1)(equal estado 'min)) (setf v 9999) 
          (loop (minimax (first sucessores) 'max) (setf sucessores (rest sucessores)) (setf v (min v *valoresF*)))))

Upvotes: 2

Views: 1103

Answers (1)

Rainer Joswig
Rainer Joswig

Reputation: 139401

RETURN needs to return from something. This something would be a block named NIL. Thus it is just a shorter version of (return-from nil ...).

A named function creates a block, but not of name NIL. The name of the block is the name of the function. Thus you have to call (return-from function-name ...).

Upvotes: 6

Related Questions