search for: destructure

Displaying 14 results from an estimated 14 matches for "destructure".

Did you mean: restructure
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
On Sat, 11 Mar 2023 11:11:06 -0500 Duncan Murdoch <murdoch.duncan at gmail.com> 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 "everything has only one value, even if it's
2023 Mar 11
2
Multiple Assignment built into the R Interpreter?
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 enables destructuring assignments. This means you can write code like: .[nr, nc] <-
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
On 11/03/2023 11:57 a.m., Ivan Krylov wrote: > On Sat, 11 Mar 2023 11:11:06 -0500 > Duncan Murdoch <murdoch.duncan at gmail.com> 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 >
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
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 expressions and have a value. > What's the value of 1 + (A, C =
2023 Mar 11
3
Multiple Assignment built into the R Interpreter?
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 = init_matrices()). I'm not sure I see the point here. I evaluated 1 + (d =
2023 Mar 12
2
Multiple Assignment built into the R Interpreter?
Thanks Gabriel and Kevin for your inputs, regarding your points Gabriel, I think Python and Julia do allow multiple sub-assignment, but in-line with my earlier suggestion in response to Duncan to make multiple assignment an environment-level operation (like collapse::%=% currently works), this would not be possible in R. Regarding the [a] <- coolest_function() syntax, yeah it would mean do
2023 Mar 12
1
Multiple Assignment built into the R Interpreter?
On 12/03/2023 6:07 a.m., Sebastian Martin Krantz wrote: > Thinking more about this, and seeing Kevins examples at > https://github.com/kevinushey/dotty > <https://github.com/kevinushey/dotty>, I think this is the most R-like > way of doing it, > with an additional benefit as it would allow to introduce the useful > data.table semantics DT[, .(a = b, c, d)] to more
2023 Mar 12
1
Multiple Assignment built into the R Interpreter?
Kevins package is very nice as a proof of concept, no doubt about that, but it is not at the level of performance or convenience that a native R implementation would offer. I would probably not use it to translate matlab routines into R packages placed on CRAN, because it?s an additional dependency, I have a performance burden in every iteration, and utils::globalVariables() is everything but
2023 Mar 13
1
Multiple Assignment built into the R Interpreter?
Dear All, As a maintainer of large, complex packages, I can think of many places in which deconstructing assignment would simplify the code, as well as facilitate readability by breaking up larger functions into helpers, so I would be very glad to see this incorporated somehow. I think the crux of the matter is that while there is a number of ways to implement deconstructing assignment within R,
2023 Mar 13
1
Multiple Assignment built into the R Interpreter?
Yes, this is really a problem with the checks, not with the language. A simpler approach than your alternativeAssignment function would be simply to allow globalVariables() to be limited to a single function as the note in its help page says. This might be tedious to write by hand, but could be automated using methods like "dotify" in dotty. Duncan Murdoch On 12/03/2023 10:36
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
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) && length(tmp) == 2) a <<- tmp[[1]] b <<- tmp[[2]] }) Do we expect [a[1], b[3]]
2018 Sep 21
3
backup of tdb files
...\E1\8C\03{\81\D3\8B\D9\D5\81\C4-\02\E8Cq\F9\A1[\F4\19\A7\22\D5\C4\A8~\B1\A6;\85;\F4\0C\CC\B6\86\99\8C\FF\9E\9A\17\02\00\00\00\06\00\00\00\00\00\00\00\06\00\00\00UNDEF\00\00\00\07\00\00\00\00\00\00\00\07\00\00\00UNDEF$\00\00\00\00\00\00" } How stable are those values? Is there a way to destructure them for the backup to reconstruct them during restore in case the format changes? What about portability? Are tdb contents platform independent? Is a secrets.tdb created with 32 bit Samba usable on a 64 bit build and vice versa? Thanks, Philipp -------------- next part -------------- A non-tex...
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
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, "list") > ?? if(length(lhs)
2018 Sep 21
0
backup of tdb files
...> \02\E8Cq\F9\A1[\F4\19\A7\22\D5\C4\A8~\B1\A6;\85;\F4\0C\CC\B6\86\99\8C > \FF\9E\9A\17\02\00\00\00\06\00\00\00\00\00\00\00\06\00\00\00UNDEF\00\ > 00\00\07\00\00\00\00\00\00\00\07\00\00\00UNDEF$\00\00\00\00\00\00" >         } > > How stable are those values? Is there a way to destructure them > for the backup to reconstruct them during restore in case the > format changes? Thankfully this file and these values shouldn't be needed.  > What about portability? Are tdb contents platform independent? Is > a secrets.tdb created with 32 bit Samba usable on a 64 bit build...