You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a bit of a tough time deciding when to return a list_of<> from a vctrs function vs just a bare list. For example, vec_chop() returns a list_of<>:
But this is slightly problematic because it is often used as a "low level" function where I really just want a bare list back. Like here in as_df_row_impl()
And here where I planned to implement vec_cast.list.data.frame
vec_cast.list.data.frame<-function(x, to, ...) {
row.names(x) <-NULL# returns list_of()out<- vec_chop(x)
attributes(out) <-NULL# alternative - much slower#out <- map(vec_seq_along(x), vec_slice, x = x)out
}
@lionel- and I think that vec_chop() should just return a bare list, but we would like to be consistent about this and make a systematic change in all vctrs functions. For example, would it still make sense for vec_split() to return a list_of<>?
I don't have a strong preference; I think in general it's better to return the most specific type (which would be list_of<> here), but we have relatively little experience with list_of<>, so we probably don't want to use it in too many places. (And it provides relatively little benefit over list)
I have a bit of a tough time deciding when to return a
list_of<>
from a vctrs function vs just a bare list. For example,vec_chop()
returns alist_of<>
:But this is slightly problematic because it is often used as a "low level" function where I really just want a bare list back. Like here in
as_df_row_impl()
vctrs/src/bind.c
Line 175 in 2c8dd41
And here where I planned to implement
vec_cast.list.data.frame
@lionel- and I think that
vec_chop()
should just return a bare list, but we would like to be consistent about this and make a systematic change in all vctrs functions. For example, would it still make sense forvec_split()
to return alist_of<>
?@hadley what do you think about this?
The text was updated successfully, but these errors were encountered: