cl-str icon indicating copy to clipboard operation
cl-str copied to clipboard

Fix style-warnings undefined function

Open kilianmh opened this issue 3 years ago • 3 comments

; in: DEFUN SUFFIX? ; (STR:ENDS-WITH-P SUFFIX S) ; caught STYLE-WARNING: undefined function: STR:ENDS-WITH-P ; in: DEFUN PREFIX? ; (STR:STARTS-WITH-P PREFIX S) ; caught STYLE-WARNING: undefined function: STR:STARTS-WITH-P

  • Define ENDS-WITH-P and STARTS-WITH-P with DEFUN
  • Define ENDS-WITH? and STARTS-WITH? with (SETF (FDEFINITION ...))

-> Avoid 2 style-warnings when loading STR

kilianmh avatar Jul 23 '22 08:07 kilianmh

Should SBCL be mentioned in the commit message, or leave it how it is?

kilianmh avatar Jul 23 '22 09:07 kilianmh

Seriously, you don't get style warnings for the two ones that are now set with setf fdefinition?

vindarel avatar Jul 23 '22 14:07 vindarel

Defing a function with setf fdefinition and using in the same file (here ends-with-p in suffix? and starts-with-p in prefix?) appears to be problematic for SBCL when loading a library (here str) the first time. I am not sure if this behavior is intended or a bug in SBCL.

One way to shut down the warning is to wrap the defun AND setf fdefinition in eval-when. That makes the functions available at compile time but adds one code line.

Instead the proposed solution simply defines the "-p" functions with defun and the "?" with setf fdefinition. This is also more in accordance with the lisp-lang.org Style Guide.

kilianmh avatar Jul 25 '22 10:07 kilianmh