Can I rename keywords in R?

I would like to achieve something like this:

se    <- .Primitive("if")
senao <- .Primitive("else") # I get an error here
para  <- .Primitive("if")

# The code I would like to run
se (1 == 1){
  # Some code
} senao {
  #more code
}

# This also doesn't work
para(1 in 1:3)
{
  print(i)
}

I would like to use the mechanism above to teach children who don't know how to speak English yet how to program. Thanks in advance.

Upvotes: 3

Views: 96

Answers (1)

MrFlick
MrFlick

Reputation: 206401

Nope. This is not possible in R. The parser has special cases for certain keywords. They cannot be changed (without altering the source code for R and compiling your own unique version).

Upvotes: 3

Related Questions