Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a direct reference?

One of the strict mode rules (Annex C) states:

When a delete operator occurs within strict mode code, a SyntaxError is thrown if its UnaryExpression is a direct reference to a variable, function argument, or function name.

So in this code:

delete x

x is a reference. (I know this because "the result of evaluating an Identifier is always a value of type Reference"). But is it a direct reference?

And, are there other kinds of references? Indirect references? (If not, what's the point of using the word "direct" at all?)

like image 779
Šime Vidas Avatar asked Sep 26 '12 20:09

Šime Vidas


1 Answers

Yes, there are different kinds of References (EcmaScript §8.7). The member operators (EcmaScript §11.2.1) for example do result in references whose base value is the value of the baseReference, which I'd call "not direct". A "direct reference" would be an identifier reference (EcmaScript §10.2.2.1, where the base value is an Environment Record.

like image 146
Bergi Avatar answered Sep 18 '22 15:09

Bergi