Survey: what new bit of syntax would you like in base #RStats?

What should the following bits of syntax do?

* ===
* ++ And --
* +=
* //
* ?
* {{ }}
* [[[ ]]]
* <<==
* (?: X)

#RStats syntax hypothetical

list1 === list2

is for performing vectorised "identical()"

#RStats syntax hypothetical

count += 2

Increases 'count' by 2

Which means the following would be valid:

p <- ggplot()
p += geom_point(...)
p += geom_text(...)

#RStats syntax hypothetical

x <- h > 3 ? 1 : 2

Steal C's ternary operator for R

@coolbutuseless FWIW ? is already an infix operator, as in package?ggplot2. And @jimhester abused it for type annotation in https://github.com/jimhester/typeCheck.
GitHub - jimhester/typeCheck: The typeCheck package automatically adds type checking code when types are annotated.

The typeCheck package automatically adds type checking code when types are annotated. - jimhester/typeCheck

GitHub

@hadleywickham @coolbutuseless @jimhester Triple it for some added personality! `???` turns a boring conditional statement into one oozing with incredulity

x <- h > 3 ??? 1 : 2

#RStats syntax hypothetical

v@x

Will access the 'x' attribute on the variable 'v'

#RStats syntax hypothetical

{{ }} initiates a mode where whitespace is significant and R code can be formatted like python

{{
for (i in x)
s += I
cat("inside loop: ", s, "\n")

print("loop finished")
}}

#RStats syntax hypothetical

for (v) {...}

is an anonymous for-loop.

Default variable is "_" or ".x" or something

#RStats syntax hypothetical

add 1 2

Bare function calls with arguments separated by space

Which gives rise to the following being allowed function calls:

git pull

luke i am your father

@coolbutuseless or

add(x)to(y) <- {
x+y
}

> add(1)to(2)
[1] 3

@coolbutuseless add a bare ',' for vector concatenation and I think you've nearly got powershell
@milesmcbain @coolbutuseless Oooh, if the R parser would just allow trailing commas in lists &c., that'd be _great_.

#RStats syntax hypothetical

mean?

This is the same as "?mean" i.e. you can put the "?" at the end of the function name to access the documentation for that function

#RStats syntax hypothetical

df . filter(x > 3) . select(a, b, c)

Bare "." as pipe operator

@coolbutuseless
Something like python mean you?

#RStats syntax hypothetical

f <- function(year, x) {
# lunar phase for xth day of year
...
}

Three dots in a row is known as The Friday Operator.

R will call an LLM and get it to write the rest of the code.

@coolbutuseless I tried this with copilot, but it just gave me a wikipedia link 
@coolbutuseless IMHO function name should be so descriptive that make comments innecessary

@coolbutuseless
++ Increment
-- decrement

Btw some of these do exist, in the tidyverse for example curly curly {{ }} calls entities within functions. Or are you talking about base R?

@coolbutuseless

* === as identical() (vectorized over list() elements, please!)

* // as integer division (like the complement of %%

* ? as a FALSE-coalescing infix operator à la `%||%`

* [[[ ]]] as a defensive version of `[[` that checks for "scalar (chr/int/etc.)" type

* (?: X) as syntactic sugar for quote()

* <<== as like <<- but assigns into ALL parent environments for maximum chaos

@yjunechoe snap!!!

I also want === to be vectorised 'identical()'

@coolbutuseless We already have `<-` and `->`, so why can't I assign up or down?

Let's add `^` and `v` assignment.

rostrum.blog - Down with R’s assignment flamewars!

@coolbutuseless also, I want to propose `<--` for assigning in the parent frame, or `<---` for in the parent's parent and so on.

The length of the tail is how far back to assign.

@coolbutuseless <| the left pipe, thus allowing <|>, the questionable dot product of two nonexistent wave functions, and |><| that would presumably create code from nothing or annihilate it at a whim