Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values of path expressions #1524

Open
mattheww opened this issue Jul 12, 2024 · 0 comments
Open

Values of path expressions #1524

mattheww opened this issue Jul 12, 2024 · 0 comments

Comments

@mattheww
Copy link
Contributor

mattheww commented Jul 12, 2024

The "Path expressions" section says:

  • "A path used as an expression context denotes either a local variable or an item.", and

  • "Path expressions that resolve to local or static variables are place expressions, other paths are value expressions.".

But it doesn't say how to get from an item or a local variable to a value or a place.

First, it should be saying that the path which makes up the expression is resolved in the value namespace.

Then it needs to cover each kind of entity that can appear in the value namespace, and explain how to use one to get a value or a place (and so also determine the expression's type).

For example:

  • for a function item, the type is the corresponding function item type and the value is that type's unique member

  • for a constant item, the type is the Type from the ConstantItem and the value is obtained by evaluating the expression in the ConstantItem

  • for a static item, the type is the Type from the StaticItem and the place represents the memory location represented by that static item

For a path that resolves to a local variable (or function parameter) things aren't so simple.

I suggest a reasonable approach for the Reference's current depth would be something along the following lines:

  • acknowledge that the notion of evaluating an expression isn't defined in isolation, but relative to an evaluation context

  • say that at runtime the evaluation context contains (at least) a chain of activation frames, corresponding to the functions which have been called and have not yet returned

  • say that an activation frame for a function contains a map from the function's local bindings to memory locations which are allocated when the function is called

  • say that for a path expression which resolves to a local binding the type is that binding's type, and the place represents the memory location that binding maps to in the last activation frame in the chain (which is necessarily an activation frame for the function containing the path expression).

I see that at present there is some wording about activation frames in the "return expressions" section, though nothing in "Call expressions".

See also #949 and #1489, and ferrocene/specification#466 (which is an earlier writeup of this issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant