-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
join
type and body don't match
#65
Comments
So the issue is that
Which makes sense. You fixed it with
You also wanted type declarations for join: #51
a list of anything? Would that be compatible with your previous request?
you mean to simplify the body? When tried at the REPL, it blows before entering the function. Is there a way to keep the type declarations, but still allow to run the function with any arguments? Also we could accept a list of numbers: (declaim (ftype (function ((or null character string)
(or null
(cons string)
(cons number)
))
string)
join)) but… nah, that's smelly. |
To clarify: I wanted the type declaration for the return value. I initially didn't know that str:join (from version 0.19) accepted lists Now that I see it does, I can think of two options:
Yes, since my previous request was about the return type.
That's because the type declaration is not approriate for this.
Indeed, one may ask "why numbers and not symbols or characters?" I think it's better to stick to an "everything or nothing" logic. Here are my suggestions.
(declaim (ftype (function (string list) string) join))
; Same function.
(declaim (ftype (function ((or null character string)
(or null (cons string)))
string)
join))
(defun join (separator strings)
"Join all the strings of the list with a separator."
(apply #'concatenate 'string (serapeum:intersperse separator strings))) Thoughts? (Edit: Typos) |
See
cl-str/str.lisp
Line 176 in 507ec6c
I was recently bit this (see atlas-engineer/nyxt#1217 if you want to get confused :p):
join
used to accept a list of anything and leverageformat
to turn the list elements to strings usingprint-object
.But since 51feb40#diff-8793bcbd16d1dc95956881ad175e7b1ad86aabfbdbf037975049fd71200af390 the function type only allows list of strings, while the body has remained the same.
So I suggest
list
arg(apply #'concatenate 'string ARG)
to match the new signature.Thoughts?
(Edit: Typos.)
The text was updated successfully, but these errors were encountered: