decorator
decorator copied to clipboard
Package
I just discover your work, I come from Python.
Would be great if there were a package.
Bests regards,
Thanks for your interest!
Would be great if there were a package.
At the moment the module is unfinished and mostly at the prototype stage: I haven’t had time to implement a prefix syntax (#1), and doing so is nontrivial.
That said, this will (probably) never be published as a package, since I’m not a fan of the R package mechanism. Coming from Python, you might be able to empathise. Instead, I would publish this as a ‘box’ module. For all intents and purposes I consider ‘box’ modules as the modern replacement of R packages.
(At any rate it’s good to know that people are potentially interested in this, because it helps me prioritising work on it.)
That said, this will (probably) never be published as a package, since I’m not a fan of the R package mechanism. Coming from Python, you might be able to empathise. Instead, I would publish this as a ‘box’ module. For all intents and purposes I consider ‘box’ modules as the modern replacement of R packages.
I saw your box project, it's very interesting. I've not deeped into yet, but I definetely would, if you show an example with decorator.
I let you close the issue. Thanks again.
I really need to clean up this repository. The runnable examples are currently not in the README
but rather in the examples.rmd
file.
But bear in mind that I’m working on changing the API. That is, instead of
echo = logged(stdout()) %@% twice %@% function (msg) {
message(msg)
}
The aim of this module is to support writing
logged[stdout()] %@%
twice %@%
echo = function (msg) {
message(msg)
}
I.e. to be closer to the placement in the corresponding Python syntax.
However, getting this to work is unfortunately quite tricky (and already contains concessions to R’s syntax — note the square brackets in logged[stdout()]
; they’re necessary since having a function call in this syntactic position doesn’t work).
Just piling on here. I find this code extremely useful, as it is now. Would be great as a standalone package with no dependencies.
It's pretty syntactically pleasing...
library(decorator)
task <-
log %@%
time %@%
function(a, b, sleep=0.02) {
for (i in seq(a, b)) {
cat(i)
cat("..")
Sys.sleep(sleep)
}
}