cannot understand the definition of "row-major-ref" in sbcl

common-lisp, sbcl

Solution

In `src/compiler/array-tran.lisp` you can also find this code:

(deftransform row-major-aref ((array index))
  `(hairy-data-vector-ref array
                          (%check-bound array (array-total-size array) index)))

I'm not an expert in SBCL internals, but I assume that `row-major-aref` is treated by the compiler as the "basic" operation that is not reduced to other Lisp function calls, but rather transformed to machine code.

Problem

The definition is from src/code/array.lisp of sbcl. It looks like an infinite loop? I didn't find any clue to get it. Any hint? Thank you! ``` (defun row-major-aref (array index) | #!+sb-doc | "Return the element of array corressponding to the row-major index. This is | SETF'able." | (declare (optimize (safety 1))) | (row-major-aref array index)) ```

Original source