[Rd] Multiple Assignment built into the R Interpreter?
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Sat Mar 11 17:57:08 CET 2023
On Sat, 11 Mar 2023 11:11:06 -0500
Duncan Murdoch <murdoch.duncan using 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
sometimes invisible(NULL)") to "structured binding" / "destructuring
assignment" [*], which takes this single single value returned by the
expression and subsets it subject to certain rules? It may be easier to
make a decision on the semantics for destructuring assignment (e.g.
languages which have this feature typically allow throwing unneeded
parts of the return value away), and it doesn't seem to break as much
of the rest of the language if implemented.
I see you've already mentioned it ("JavaScript-like"). I think it would
fulfil Sebastian's requirements too, as long as it is considered "true
assignment" by the rest of the language.
The hard part is to propose the actual grammar of the new feature (in
terms of src/main/gram.y, preferably without introducing conflicts) and
its semantics (including the corner cases, some of which you have
already mentioned). I'm not sure I'm up to the task.
--
Best regards,
Ivan
[*]
https://en.cppreference.com/w/cpp/language/structured_binding
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
More information about the R-devel
mailing list