Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread avi.e.gross
I am not personally for or against changes to the R main language but do find that too many people keep wanting to change R so it should be like some other language. Many features would be nice, especially if they do not break existing code, but the time and effort and other overheads need to be

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Kevin Ushey
FWIW, it's possible to get fairly close to your proposed semantics using the existing metaprogramming facilities in R. I put together a prototype package here to demonstrate: https://github.com/kevinushey/dotty The package exports an object called `.`, with a special `[<-.dot` S3 method which

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Gabriel Becker
There are some other considerations too (apologies if these were mentioned above and I missed them). Also below are initial thoughts, so apologies for any mistakes or oversights. For example, if [a, b] <- my2valuefun() works the same as local({ tmp <- my2valuefun() stopifnot(is.list(tmp) && len

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Duncan Murdoch
On 11/03/2023 4:42 p.m., Sebastian Martin Krantz wrote: Thanks Duncan and Ivan for the careful thoughts. I'm not sure I can follow all aspects you raised, but to give my limited take on a few: your proposal violates a very basic property of the language, i.e. that all statements are expressi

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Duncan Murdoch
On 11/03/2023 4:42 p.m., Sebastian Martin Krantz wrote: Thanks Duncan and Ivan for the careful thoughts. I'm not sure I can follow all aspects you raised, but to give my limited take on a few: your proposal violates a very basic property of the language, i.e. that all statements are expressi

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Sebastian Martin Krantz
Thanks Duncan and Ivan for the careful thoughts. I'm not sure I can follow all aspects you raised, but to give my limited take on a few: > your proposal violates a very basic property of the language, i.e. that all > statements are expressions and have a value. > What's the value of 1 + (A, C =

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Duncan Murdoch
On 11/03/2023 11:57 a.m., Ivan Krylov wrote: On Sat, 11 Mar 2023 11:11:06 -0500 Duncan Murdoch wrote: That's clear, but your proposal violates a very basic property of the language, i.e. that all statements are expressions and have a value. How about reframing this feature request from multi

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Ivan Krylov
On Sat, 11 Mar 2023 11:11:06 -0500 Duncan Murdoch wrote: > That's clear, but your proposal violates a very basic property of the > language, i.e. that all statements are expressions and have a value. How about reframing this feature request from multiple assignment (which does go contrary to "

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Duncan Murdoch
On 11/03/2023 9:54 a.m., Sebastian Martin Krantz wrote: Thanks Duncan, I know about list2env(), in fact a previous version of collapse::`%=%` was coded as "%=%" <- function(lhs, rhs) {    if(!is.character(lhs)) stop("lhs needs to be character")    if(!is.list(rhs)) rhs <- as.vector(rhs, "li

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Sebastian Martin Krantz
Thanks Duncan, I know about list2env(), in fact a previous version of collapse::`%=%` was coded as "%=%" <- function(lhs, rhs) { if(!is.character(lhs)) stop("lhs needs to be character") if(!is.list(rhs)) rhs <- as.vector(rhs, "list") if(length(lhs) != length(rhs)) stop("length(lhs) not e

Re: [Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Duncan Murdoch
I think the standard way to do this in R is given by list2env(), as described in a couple of answers on the SO page you linked. The syntax you proposed would be likely to be confusing in complex expressions, e.g. f(A, C, Q, R = init_matrices(X, Y, Z)) would obviously not work but wouldn't

[Rd] Multiple Assignment built into the R Interpreter?

2023-03-11 Thread Sebastian Martin Krantz
Dear R Core, working on my dynamic factor modelling package, which requires several subroutines to create and update several system matrices, I come back to the issue of being annoyed by R not supporting multiple assignment out of the box like Matlab, Python and julia. e.g. something like A, C, Q