Transparent identifiers
Certain translations inject range variables with transparent identifiers denoted by *. Transparent identifiers are not a proper language feature; they exist only as an intermediate step in the query expression translation process. When a query translation injects a transparent identifier, further translation steps propagate the transparent identifier into anonymous functions and anonymous object initializers. In those contexts, transparent identifiers have the following behavior: · When a transparent identifier occurs as a parameter in an anonymous function, the members of the associated anonymous type are automatically in scope in the body of the anonymous function. · When a member with a transparent identifier is in scope, the members of that member are in scope as well. · When a transparent identifier occurs as a member declarator in an anonymous object initializer, it introduces a member with a transparent identifier. In the translation steps described above, transparent identifiers are always introduced together with anonymous types, with the intent of capturing multiple range variables as members of a single object. An implementation of C# is permitted to use a different mechanism than anonymous types to group together multiple range variables. The following translation examples assume that anonymous types are used, and show how transparent identifiers can be translated away. The example from c in customers is translated into from * in customers. which is further translated into customers. which, when transparent identifiers are erased, is equivalent to customers. where x is a compiler generated identifier that is otherwise invisible and inaccessible. The example from c in customers is translated into from * in customers. which is further reduced to customers. the final translation of which is customers. where x, y, and z are compiler generated identifiers that are otherwise invisible and inaccessible.
|