Here's a function I was writing that will generate a number list based on a start value, end value and a next function.

```
(defun gen-nlist (start end &optional (next #'(lambda (x) (+ x 1))))
    (labels ((gen (val lst)
        (if (> val end) 
            lst
            (cons val (gen (next val) lst)))))
    (gen start '())))

```

However when entering it into the SBCL repl I get the following warnings:

```
; in: DEFUN GEN-NLIST
;     (SB-INT:NAMED-LAMBDA GEN-NLIST
;         (START END &OPTIONAL (NEXT #'(LAMBDA (X) (+ X 1))))
;       (BLOCK GEN-NLIST
;         (LABELS ((GEN #
;                    #))
;           (GEN START 'NIL))))
; 
; caught STYLE-WARNING:
;   The variable NEXT is defined but never used.

;     (NEXT VAL)
; 
; caught STYLE-WARNING:
;   undefined function: NEXT
; 
; compilation unit finished
;   Undefined function:
;     NEXT
;   caught 2 STYLE-WARNING conditions

```

Somehow it does see the variable next as defined, but not used.
And where I do use it, as in `(next val)`, it's an undefined function?!

Clearly I'm doing something wrong here. I just can't figure what or how.
Is this the correct way of specifying optional function arguments with default values?