typed icon indicating copy to clipboard operation
typed copied to clipboard

Naming convention

Open latot opened this issue 2 years ago • 2 comments

Hi!, something to add to https://github.com/moodymudskipper/typed/issues/53 but I think this also would be good to be in its own issue too.

I'm having a lot of problems with the naming conventions, typed needs to us create new types + vctrs, also some other things, here an example:

#' @export
Node_ <- typed::as_assertion_factory(function(value) {
  value <- typed::Integer(anyNA = FALSE, null_ok = FALSE)(value)
  value
})

#' @export
is_node <- function(x) {
  inherits(x, "node")
}

#' @export
Node <- function() Node_(is_node = TRUE)

#' @export
#' @name node
node <- Node() ? function(x = ? Node_()) {
  vctrs::new_vctr(x, class = "node")
}

#' @export
#' @name node_inv
node_inv <- Node_() ? function(x = ? Node()) {
  as.vector(x)
}

But this is its own name convention, in R is common the snake_case convention and above code does not follow it, but I also still don't found a good/clear way to get one, so I think is a need have in the docs how to organize this.

Thx!

latot avatar Dec 18 '23 15:12 latot

I personally use snake case all the time, starting with a capital letter was a way to be able reuse existing names, such as integer. A capital letter also shows that these are unusual objects, R6 does it too for its class objects, then uses snake case everywhere else. I can mention this in the doc.

moodymudskipper avatar Dec 18 '23 16:12 moodymudskipper

mm, I think something must be done with Lintr for CI.

Also, there is a need to a lot of names, is important be able to notice them, we could use full mayus for types.

latot avatar Dec 18 '23 19:12 latot