Shen
Shen

Reputation: 147

How are expression objects (EXPRSXP) used in R?

I was wondering how expression objects (EXPRSXP) are used in R? It seems to me that R almost always using call objects to carry out the language computation. Any one could point to me some places that expression objects are used instead of call objects?

Another side question... for three points in a promise, does the third pointer pointing to an call object (LANGSXP) or an expression object (EXPRSXP)?

Thanks, Shen

Upvotes: 0

Views: 103

Answers (1)

BrodieG
BrodieG

Reputation: 52647

The return value of parse is an expression, so this would be a common use case for expressions (I've used expressions a fair bit in this type of context).

str(parse(text="1 + 1\n2+2"))
# length 2 expression(1 + 1, 2 + 2)

Promises are documented as containing expressions, though in most cases presumably they would be 1 length expressions, so effectively a call/symbol, though probably still stored as an expression (I'm speculating here).

Upvotes: 1

Related Questions