Skip to content

Allow modify() to modify calls #412

Closed

Description

@hadley
library(rlang)
library(purrr)

x <- expr(foo(a, b, 10))
modify(x, ~ if (is.numeric(.x)) .x + 10 else .x)

We should probably expand the vector definition to include pairlists (this will require custom code but it's probably worth it as the connections between purrr and rlang become stronger)

Activity

  1. hadley commented on Nov 20, 2017

    @hadley
    MemberAuthor

    For map(), this will require a different approach to map_impl() + call_loop() which currently generates calls of the form f(x[[i]]) modifying the value of i in an environment. Instead will need to generate __x_i by looping over the pairlist. For efficiently, will also need to name output as we go using the TAG().

    May also be worth a custom modify() method because replacement with [[<- is unlikely to be efficient.

    In the short term, might be better to just coerce back and forth to a list, not worrying about efficiency.

  2. hadley commented on Nov 20, 2017

    @hadley
    MemberAuthor

    Actually we can just rely on the fact that [[ has an existing implementation

  3. added a commit that references this issue on Jan 10, 2025
    1caf625
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions