Skip to content

[Query] Inspect Argument Roles

github-actions[bot] edited this page Nov 8, 2026 · 1 revision

Generated from 'wiki-query.ts' on 2026-11-08, 14:25:27 UTC (v2.17.4), do not edit directly.

Inspect Argument Roles Query [overview]

Determine what functions and their formals do
This query is requested with the type inspect-fn-props.
Run in the REPL: :query @inspect-fn-props [(<crit>;...)] <code | file://path>

Per function definition this states what each formal is used for, as ArgProp bits, and what the function itself does, as CallProp bits: the very scheme flowR states its built-ins and the signature database stores its parameters with.

R hands arguments over as promises, so whether a parameter is evaluated at all is part of the answer: ArgProp::Forced says every call forces it, ArgProp::Lazy that none can, and neither of the two that it depends on the path taken, on the caller, or on a function flowR could not resolve. A function forcing every one of its parameters is CallProp::Strict in turn. A read that only hands the parameter on is decided by the function receiving it, resolved through the call graph, while a read in a nested definition, in a loop, or under a condition leaves it open.

A formal is an alias only if the function always returns it (return(x) under an if does not count), every other bit is the one the calls in the body state for what they are handed, and a formal carrying none at all is left out. A body reading its own call or frame (match.call(), nargs(), as.list(environment())) reaches every formal without naming one, so they all carry nse. What the function itself does is read off its body: what its calls do it does too, a dispatching body is a generic, and one whose result always comes from a call returning invisibly returns invisibly in turn.

With only the query infers just one half (arguments or function, skipping the other walk entirely), formals keeps the parameters written as one of the given names, and props keeps the properties named as the ArgProp/CallProp members they are.

Using the example code f <- function(x, xs, FUN, opt) { if(missing(opt)) print(length(xs)); lapply(xs, FUN); x } the following query returns what every identified function and formal does:

[ { "type": "inspect-fn-props" } ]

(This can be shortened to @inspect-fn-props when used with the REPL command :query).

Results (prettified and summarized):

Query: inspect-fn-props
  - Function 32 (1.6-89) x: forced, alias, xs: forced, value, shape, FUN: forced, callee, opt: presence, lazy [prints]

Show Detailed Results as Json

The analysis ran (including parsing and normalization and the query) within the generation environment.

The JSON contains the ids of the nodes in question (see the Interface wiki page).

{"inspect-fn-props":{".meta":{},"roles":{"32":{"1":5,"3":25,"5":513,"7":17408}},"props":{"32":{"props":0,"tags":["prints"]}}},".meta":{}}
Original Code
f <- function(x, xs, FUN, opt) { if(missing(opt)) print(length(xs)); lapply(xs, FUN); x }

This query also supports a slicing criterion based query mode that only returns information for functions matching the given criteria:

[ { "type": "inspect-fn-props",   "filter": [ "1@function" ] } ]

(This can be shortened to @inspect-fn-props (1@function) "f <- function(x, xs, FUN, opt) { if(missing(opt)) print(length(xs)); lapply(xs, FUN); x }" when used with the REPL command :query).

Results (prettified and summarized):

Query: inspect-fn-props
  - Function 32 (1.6-89) x: forced, alias, xs: forced, value, shape, FUN: forced, callee, opt: presence, lazy [prints]

Show Detailed Results as Json

The analysis ran (including parsing and normalization and the query) within the generation environment.

The JSON contains the ids of the nodes in question (see the Interface wiki page).

{"inspect-fn-props":{".meta":{},"roles":{"32":{"1":5,"3":25,"5":513,"7":17408}},"props":{"32":{"props":0,"tags":["prints"]}}},".meta":{}}
Original Code
f <- function(x, xs, FUN, opt) { if(missing(opt)) print(length(xs)); lapply(xs, FUN); x }
Implementation Details

The Inspect Argument Roles Query is executed by executeFnPropsQuery.

Clone this wiki locally

⌂ 换网址