vindarel / cl-str

Modern, simple and consistent Common Lisp string manipulation library.
https://vindarel.github.io/cl-str/
MIT License
305 stars 37 forks source link

Fix: casing functions inconsistencies #93

Closed kilianmh closed 1 year ago

kilianmh commented 1 year ago

Closes #91 The no-case could also be implemented like this:

  (defun no-case (s &key (replacement nil replacement-p))
  "Return the no-cased version of `s'.
  Calls `cl-change-case:no-case' after coercing `s' into a string,
  but returns nil if `s' is nil."
  (when s
    (if replacement-p
        (cl-change-case:no-case (string s) :replacement replacement)
        (cl-change-case:no-case (string s)))

One idea that appeared was to add the documentation of cl-change-case to our casing functions with #. Something like this:

  (defun dot-case (s)
  #.(concat (documentation 'cl-change-case:dot-case 'function)
  "Return the dot-cased version of `s'.
  Calls `cl-change-case:dot-case' after coercing `s' into a string,
  but returns nil if `s' is nil.")
  (when s
    (cl-change-case:dot-case (string s))))

Then the REPL documentation would be more helpful for str:dot-case etc. On the other hand it might reduce readability of the code.

vindarel commented 1 year ago

Thanks again. I think writing the docstring is fine. If the upstream one changes it could turn inappropriate for us.

However I find their docstrings clearer:

Transform STRING to lower case space delimited. Use REPLACEMENT as delimiter.

Would you mind changing them?

(and if you're up to it, adding a simple example. I can do it later too)

ps: you could on the other hand factorize the part "Calls cl-change-case:dot-case' after coercings' into a string, but returns nil if `s' is nil.", maybe, but there's no real need, once we do the copy-paste it's done.

kilianmh commented 1 year ago

Now the docstrings are copied from cl-change-case and examples are added for all types (string, symbol, character, nil)