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

#28 Adds discussion of location propagation #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jtoman
Copy link
Contributor

@jtoman jtoman commented Jun 27, 2023

Attempts to clarify what the located type does and how it would be used to model existing solidity types and the future plans for explicit data locations.

Once again tagging @cameel because I can't request a review.

Closes #28.

Attempts to clarify what the located type does and how it would be used
to model existing solidity types and the future plans for explicit data
locations.
@cameel cameel self-requested a review June 28, 2023 17:04
Copy link
Contributor

@cameel cameel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good way to address this and yeah, this does reflect Solidity type system better. I think it's a clear improvement and a good addition.

I have some remarks about references though.

Also typos. Lots of typos :P

##### Location Propagation

Reference types (that is, those types for which data location is relevant: `mapping`, `array`,
`static_array`, or `struct`) do **not** explicitly include location information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to the PR, but this makes me wonder - do we want to have a distinct type representing array slices? Solidity does have one, though it's not nameable and values of these types are used pretty much like arrays so it's not very apparent to the user. Might be relevant to a debugger though.

docs/source/format.md Outdated Show resolved Hide resolved
What follows is an attempt at formal rigor.
Define a "well-located" type description _wt_ to be an entry
in the `types` array where the following condition is true: any reference type (`mapping`, `array`,
`static_array`, or `struct`) reachable from _wt_ must encounter at least one `located` type.
Copy link
Contributor

@cameel cameel Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the spec should not limit this to specific sorts of types. Solidity already allows more - you can have located value types too, e.g. uints in storage. You cannot have local variables storing references to them, but that's a bit of an artificial restriction and some languages might even allow that. In fact we're currently in the process of redesigning how references work in Solidity and it's likely that we'll relax this restriction ourselves.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, being a reference and having a location are two distinct concepts. Like, a variable can be of a reference type or of a value type. And the target of the reference always has some location. For local variables that's just "stack" (though stack-to-memory mover mechanism complicates that notion a bit).

Solidity tries hard to hide this distinction and I wonder if it should be precisely reflected in the spec or not. It's all at the level of implementation details. On the other hand, these details are probably relevant to debuggers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that these details would have been enormously helpful many years ago when @truffle/debugger was getting started :)

docs/source/format.md Outdated Show resolved Hide resolved
docs/source/format.md Outdated Show resolved Hide resolved
docs/source/format.md Outdated Show resolved Hide resolved
docs/source/format.md Outdated Show resolved Hide resolved
docs/source/format.md Outdated Show resolved Hide resolved
docs/source/format.md Outdated Show resolved Hide resolved
Comment on lines 285 to 286
The downside of this choice is that not all entries in the `types` array have an unambigous interpretation,
only those that meet the criteria of well-located given above.
Copy link
Contributor

@cameel cameel Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't really call it a downside. If every type in the language has to ultimately have a location, the spec could require that there exists a well-located version of it somewhere in the types array. And if not, then it's actually an advantage because we it lets us express types generic with regard to location (which will be a part of Solidity in the future).

Co-authored-by: Kamil Śliwak <[email protected]>
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

Successfully merging this pull request may close these issues.

located types vs generic locations
3 participants