Skip to content

Eliminate [[ if ordinary indexing can carry the semantics #14

Description

@isomorphisms

Goal

Try to remove R's [[ indexing form from normal IR code.

This is not an objection to bracket-heavy syntax. Brackets are fast and useful for data analysis. The problem is making the programmer choose between [ and [[ for closely related indexing/extraction operations when a simpler rule may suffice.

Desired ordinary notation includes forms such as:

x[3]
x[3:5]
x[mask]
matrix[i, j]
e$frog

Questions to settle:

  • Can scalar x[i] simply extract the indexed element, while ranges/masks naturally produce collections?
  • Is there any important R [[ behavior that cannot be expressed cleanly through ordinary [], $, or an explicitly named uncommon operation?
  • What happens for lists, data frames, arrays, environments, recursive indexing, missing names, and replacement operations?
  • What compatibility lowering is needed for imported R code that uses [[?

The burden of proof should be on retaining [[. If it represents a genuinely necessary semantic distinction, document that distinction with examples. Otherwise compile it away during R-to-IR translation and keep it out of the normal IR surface language.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions