[rkward] packages/rkwarddev: removed public documentation for "for" loops in js()

m.eik michalke meik.michalke at uni-duesseldorf.de
Fri Oct 30 14:06:02 UTC 2015


Git commit 4c0b18f4af93b0a356f485e6e464cf73c19fc7ce by m.eik michalke.
Committed on 30/10/2015 at 14:06.
Pushed by meikm into branch 'master'.

removed public documentation for "for" loops in js()

  - the code remains in place for experiments, but no-one should use it productively

M  +4    -2    packages/rkwarddev/ChangeLog
M  +1    -1    packages/rkwarddev/DESCRIPTION
M  +1    -16   packages/rkwarddev/R/js.R
M  +19   -0    packages/rkwarddev/R/rk-internal.R
M  +1    -1    packages/rkwarddev/R/rkwarddev-package.R
M  +4    -2    packages/rkwarddev/inst/NEWS.Rd
M  +1    -20   packages/rkwarddev/man/js.Rd
M  +1    -1    packages/rkwarddev/man/rkwarddev-package.Rd

http://commits.kde.org/rkward/4c0b18f4af93b0a356f485e6e464cf73c19fc7ce

diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index b5bc8d1..23f86a5 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -1,6 +1,6 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.07-4 (2015-10-28)
+changes in version 0.07-4 (2015-10-30)
 unreleased:
   - this version is under development
 fixed:
@@ -19,7 +19,9 @@ added:
     duplicates (e.g., <copy>)
   - new wrapper function js() for id() makes it possible to use several
     operators without quoting, preserve "if" conditions and "for" loops, which all
-    will be translated to JavaScript equivalents without the need for quoting
+    will be translated to JavaScript equivalents without the need for quoting.
+    however, the "for" loop code is not publicly documented and remains a
+    proof of concept kind of thing for now
   - new option ".objects" in id() to provide objects as a list
   - new option "rk.JS.vars" to make JS variables match the name of the
     original R object
diff --git a/packages/rkwarddev/DESCRIPTION b/packages/rkwarddev/DESCRIPTION
index 18ec091..c051e14 100644
--- a/packages/rkwarddev/DESCRIPTION
+++ b/packages/rkwarddev/DESCRIPTION
@@ -17,7 +17,7 @@ URL: https://rkward.kde.org
 Authors at R: c(person(given="m.eik", family="michalke",
         email="meik.michalke at hhu.de", role=c("aut", "cre")))
 Version: 0.07-4
-Date: 2015-10-28
+Date: 2015-10-30
 Collate:
     '00_class_01_rk.JS.arr.R'
     '00_class_02_rk.JS.var.R'
diff --git a/packages/rkwarddev/R/js.R b/packages/rkwarddev/R/js.R
index e2e3584..8b5cfeb 100644
--- a/packages/rkwarddev/R/js.R
+++ b/packages/rkwarddev/R/js.R
@@ -21,18 +21,12 @@
 #' This function is a wrapper for \code{\link[rkwarddev:id]{id}} similar to \code{\link[rkwarddev:qp]{qp}}
 #' that uses \code{eval(substitute(alist(...)))} to preserve the value of \code{...} as-is to be able to
 #' both keep operators like \code{">="} or \code{"!="} unevaluated in the resulting output, as well as translating
-#' \code{if/else} clauses and \code{for} loops from R to JavaScript.
+#' \code{if/else} clauses from R to JavaScript.
 #' 
 #' Normally, \code{id} would simply evaluate the condition and then return the result of that evaluation, which
 #' most of the time is not what you want. With this function, you can test conditions in usual R syntax, yet
 #' the operators and \code{if/else} clauses will end up pasted in the result.
 #' 
-#' Using \code{for} loops is a bit more delicate, as they are very differently constructed in JavaScript. As
-#' a workaround, \code{js} will define an array and a counter variable with randomly generated names, fill
-#' the array with the values you provided and iterate through the array. In order to keep the iterator variable
-#' name you used in the original R loop, so you can use it inside the loop body, you will have to define it before
-#' the \code{js} call with a substitution of itself (see examples). Otherwise, you will get an "object not found" error.
-#' 
 #' The following operators are supported: +, -, *, /, ==, !=, >, <, >=, <=, || and &&
 #' 
 #' These are currently unsupported and still need to be quoted: \%, ++, --, =, +=, -=, *=, /=, \%=, ===, !== and !
@@ -59,15 +53,6 @@
 #'     echo("nothing!")
 #'   }
 #' )))
-#' 
-#' # let's try preserving a for loop
-#' # to use iterator variable i, we must initialize it first
-#' i <- substitute(i)  # DON'T FORGET THIS!
-#' cat(rk.paste.JS(js(
-#'   for (i in 1:10) {
-#'     echo(i)
-#'   }
-#' )))
 
 js <- function(..., level=2){
   full.content <- eval(substitute(alist(...)))
diff --git a/packages/rkwarddev/R/rk-internal.R b/packages/rkwarddev/R/rk-internal.R
index 5059172..b22ed2f 100644
--- a/packages/rkwarddev/R/rk-internal.R
+++ b/packages/rkwarddev/R/rk-internal.R
@@ -1554,6 +1554,25 @@ replaceJSIf <- function(cond, level=1, paste=TRUE){
 
 
 ## function replaceJSFor
+# this function is currently not publicly announced, but is available through the js() function
+# 
+#<documentation> 
+# Using \code{for} loops is a bit more delicate, as they are very differently constructed in JavaScript. As
+# a workaround, \code{js} will define an array and a counter variable with randomly generated names, fill
+# the array with the values you provided and iterate through the array. In order to keep the iterator variable
+# name you used in the original R loop, so you can use it inside the loop body, you will have to define it before
+# the \code{js} call with a substitution of itself (see examples). Otherwise, you will get an "object not found" error.
+#
+# example:
+# # let's try preserving a for loop
+# # to use iterator variable i, we must initialize it first
+# i <- substitute(i)  # DON'T FORGET THIS!
+# cat(rk.paste.JS(js(
+#   for (i in 1:10) {
+#     echo(i)
+#   }
+# )))
+#</documentation> 
 replaceJSFor <- function(loop, level=1){
   if(inherits(loop, "for")){
     # for loops must be handled differently, we need to create an array
diff --git a/packages/rkwarddev/R/rkwarddev-package.R b/packages/rkwarddev/R/rkwarddev-package.R
index f84f6f6..daf01d3 100644
--- a/packages/rkwarddev/R/rkwarddev-package.R
+++ b/packages/rkwarddev/R/rkwarddev-package.R
@@ -4,7 +4,7 @@
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
 #' Version: \tab 0.07-4\cr
-#' Date: \tab 2015-10-28\cr
+#' Date: \tab 2015-10-30\cr
 #' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr
diff --git a/packages/rkwarddev/inst/NEWS.Rd b/packages/rkwarddev/inst/NEWS.Rd
index 91ed8d4..69c0c51 100644
--- a/packages/rkwarddev/inst/NEWS.Rd
+++ b/packages/rkwarddev/inst/NEWS.Rd
@@ -1,7 +1,7 @@
 \name{NEWS}
 \title{News for Package 'rkwarddev'}
 \encoding{UTF-8}
-\section{Changes in rkwarddev version 0.07-4 (2015-10-28)}{
+\section{Changes in rkwarddev version 0.07-4 (2015-10-30)}{
   \subsection{unreleased}{
     \itemize{
       \item this version is under development
@@ -27,7 +27,9 @@
         duplicates (e.g., <copy>)
       \item new wrapper function \code{js()} for \code{id()} makes it possible to use several
         operators without quoting, preserve \code{"if"} conditions and \code{"for"} loops, which all
-        will be translated to JavaScript equivalents without the need for quoting
+        will be translated to JavaScript equivalents without the need for quoting.
+        however, the \code{"for"} loop code is not publicly documented and remains a
+        proof of concept kind of thing for now
       \item new option \code{".objects"} in \code{id()} to provide objects as a list
       \item new option \code{"rk.JS.vars"} to make JS variables match the name of the
         original R object
diff --git a/packages/rkwarddev/man/js.Rd b/packages/rkwarddev/man/js.Rd
index 7a27ce3..bed2833 100644
--- a/packages/rkwarddev/man/js.Rd
+++ b/packages/rkwarddev/man/js.Rd
@@ -21,7 +21,7 @@ This function is a wrapper for \code{\link[rkwarddev:id]{id}} similar to \code{\
 that uses \code{eval(substitute(alist(...)))} to preserve the value of \code{...} as-is to be able to
 both keep operators like \code{">="} or \code{"!="} unevaluated in the resulting output,
       as well as translating
-\code{if/else} clauses and \code{for} loops from R to JavaScript.
+\code{if/else} clauses from R to JavaScript.
 }
 \details{
 Normally,
@@ -30,16 +30,6 @@ most of the time is not what you want. With this function,
       you can test conditions in usual R syntax, yet
 the operators and \code{if/else} clauses will end up pasted in the result.
 
-Using \code{for} loops is a bit more delicate,
-      as they are very differently constructed in JavaScript. As
-a workaround,
-      \code{js} will define an array and a counter variable with randomly generated names, fill
-the array with the values you provided and iterate through the array. In order to keep the iterator variable
-name you used in the original R loop, so you can use it inside the loop body,
-      you will have to define it before
-the \code{js} call with a substitution of itself (see examples). Otherwise,
-      you will get an "object not found" error.
-
 The following operators are supported: +, -, *, /, ==, !=, >, <, >=, <=, || and &&
 
 These are currently unsupported and still need to be quoted: \%, ++, --, =, +=, -=, *=,
@@ -55,15 +45,6 @@ cat(rk.paste.JS(js(
     echo("nothing!")
   }
 )))
-
-# let's try preserving a for loop
-# to use iterator variable i, we must initialize it first
-i <- substitute(i)  # DON'T FORGET THIS!
-cat(rk.paste.JS(js(
-  for (i in 1:10) {
-    echo(i)
-  }
-)))
 }
 \seealso{
 \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
diff --git a/packages/rkwarddev/man/rkwarddev-package.Rd b/packages/rkwarddev/man/rkwarddev-package.Rd
index 7921bf7..c062118 100644
--- a/packages/rkwarddev/man/rkwarddev-package.Rd
+++ b/packages/rkwarddev/man/rkwarddev-package.Rd
@@ -12,7 +12,7 @@ A Collection of Tools for RKWard Plugin Development.
 Package: \tab rkwarddev\cr
 Type: \tab Package\cr
 Version: \tab 0.07-4\cr
-Date: \tab 2015-10-28\cr
+Date: \tab 2015-10-30\cr
 Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 Enhances: \tab rkward\cr
 Encoding: \tab UTF-8\cr



More information about the rkward-tracker mailing list