Displaying 8 results from an estimated 8 matches for "coolest_funct".
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
...fun()[[2]]
is perfectly valid R code (though it does call the function twice which is
"silly" in some sense).
Another thing which arises from the Julia API specifically which I think is
problematic is the ambiguity of's atomic "types" being vectors. Consider
the following
coolest_function <- function() c(a = 15, b = 65, c = 275)
a <- coolest_function()
That obviously makes a vector of length 3. Anything else would break *like
all the R code*
But now, what does
[a] <- coolest_function()
do? Does it assign 15 to a, because b and c arent' being assigned to?
Does th...
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?
...ng 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
multiple assignment and set a equal to the first element dropping all other
elements. Multiple assignment should be positional loke in other languages,
enabling flexible renaming of objects on the fly. So it should be
irrelevant whether the function returns a name...
2023 Mar 12
1
Multiple Assignment built into the R Interpreter?
...o 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 multiple assignment and set a equal to the first element dropping
> all other elements. Multiple assignment should be positional loke in
> other languages, enabling flexible renaming of objects on the fly.
> So it should be irrelevant...
2023 Mar 12
1
Multiple Assignment built into the R Interpreter?
...e 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 multiple assignment and set a equal to the first element dropping
> > all other elements. Multiple assignment should be positional loke in
> > other languages, enabling flexible renaming of objects on the fly.
> > So it...
2023 Mar 13
1
Multiple Assignment built into the R Interpreter?
...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 multiple assignment and set a equal to the first element
> > > dropping
> > > ??? all other elements. Multiple assignment should be positional
> > > loke in
> > > ??? other languages, enabling f...
2023 Mar 13
1
Multiple Assignment built into the R Interpreter?
...gt; ??? 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 multiple assignment and set a equal to the first element
>>>> dropping
>>>> ??? all other elements. Multiple assignment should be positional
>>>> loke in
>>>> ??? other langua...
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] <-