moodymudskipper / tag

Build function operator factories supporting the tag$function(args) notation
GNU General Public License v3.0
13 stars 1 forks source link

crayon uses tags backwards #20

Closed moodymudskipper closed 5 years ago

moodymudskipper commented 5 years ago

found this by accident :

crayon:::`$.crayon`
function (crayon, style) 
{
    attr(crayon, "_styles") <- c(attr(crayon, "_styles"), data_env$my_styles[style])
    crayon
}

library(crayon)
cat(blue("hello"))
cat(blue$bold("hello"))

$.crayon is a function operator / adverb, but instead of returning a modified rhs like tags it returns a modified lhs.

We don't have a blue function here, its is used as the index of data_env$my_styles to apply the relevant modifications.

moodymudskipper commented 5 years ago

archived