implicit return? [🇷 for BE/BA]
Dear Detlew,
Yep.
Does that really matter?
Exactly. You know that I’m facing a similar story with the forum scripts (PHP: weakly typed) generating database-queries (SQL: strongly typed). Bloody scavenger hunt.
❝ ❝ I always use explicit return(something)
in my functions,…
❝
❝ A good idea.
Yep.
❝ But if you use R you are told that doing so has the penalty of a longer run-time.
❝ Bloody Hell!
Does that really matter?
library(microbenchmark)
impl <- function(x) {
if (x == 0) {
"foo"
} else {
"bar"
}
}
expl <- function(x) {
if (x == 0) {
return("foo")
} else {
return("bar")
}
}
res <- microbenchmark(impl(round(runif(1), 0)),
expl(round(runif(1), 0)), times=2000L)
print(res)
Unit: microseconds
expr min lq mean median uq max neval cld
impl(round(runif(1), 0)) 1.811 1.812 2.686167 1.813 2.114 1383.479 2000 a
expl(round(runif(1), 0)) 1.811 1.812 2.955002 1.813 2.114 1879.152 2000 a
❝ Weakly typed (R) against strong typed language (C or C++).
Exactly. You know that I’m facing a similar story with the forum scripts (PHP: weakly typed) generating database-queries (SQL: strongly typed). Bloody scavenger hunt.
—
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
Helmut Schütz
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
Helmut Schütz
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- R Inferno Helmut 2019-04-26 16:03 [🇷 for BE/BA]
- full conditions! mittyri 2019-04-26 16:20
- full conditions! Helmut 2019-04-26 16:41
- full conditions! d_labes 2019-04-27 14:29
- magik of R implicit return mittyri 2019-04-27 22:23
- magik of R implicit return ElMaestro 2019-04-27 22:34
- implicit return? d_labes 2019-04-28 19:36
- implicit return? ElMaestro 2019-04-28 20:36
- implicit return?Helmut 2019-04-28 20:50
- implicit return? ElMaestro 2019-04-28 21:16
- implicit return? Helmut 2019-04-28 23:38
- implicit return? ElMaestro 2019-04-29 09:40
- implicit return? Helmut 2019-04-29 10:41
- implicit return? ElMaestro 2019-04-29 12:55
- built-in ifelse mittyri 2019-04-30 13:05
- implicit return? ElMaestro 2019-04-29 12:55
- implicit return? Helmut 2019-04-29 10:41
- implicit return? ElMaestro 2019-04-29 09:40
- implicit return? Helmut 2019-04-28 23:38
- implicit return? ElMaestro 2019-04-28 21:16
- implicit return? d_labes 2019-04-28 19:36
- magik of R implicit return ElMaestro 2019-04-27 22:34
- magik of R implicit return mittyri 2019-04-27 22:23
- full conditions! mittyri 2019-04-26 16:20