Skip to content

Improvements re: completing function as reference vs call #1002

@jennybc

Description

@jennybc

I think the last rounds of improvement re: function completions were in #819 and #754. For now, the heuristic for deciding whether to treat as a function reference vs. call is based on whether we're inside a list of special functions:

static FUNCTIONS_EXPECTING_A_FUNCTION_REFERENCE: &[&str] = &[
"args",
"debug",
"debugonce",
"formals",
"help",
"trace",
"str",
];

Two examples of sites where a user wants a function reference (but gets parentheses anyway) came up in posit-dev/positron#9044 (comment)

library(tidyverse)

penguins |> relocate(where(is.character()))
map(1:3, mean())

The current list only contains functions from the base and utils packages. But tidyselect::where() is a pretty clearcut case. More complicated, but also compelling is purrr::map() (and base equivalents). Not sure which will come first: improving the ad hoc list or improving the whole approach, but opening this as a place to track concrete examples that folks mention.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions