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

Feature request: mechanism to put local variables in memory #3223

Closed
tinybike opened this issue Nov 21, 2017 · 3 comments
Closed

Feature request: mechanism to put local variables in memory #3223

tinybike opened this issue Nov 21, 2017 · 3 comments
Labels
closed due inactivity The issue/PR was automatically closed due to inactivity. feature language design :rage4: Any changes to the language, e.g. new features stale The issue/PR was marked as stale because it has been open for too long.

Comments

@tinybike
Copy link
Member

tinybike commented Nov 21, 2017

One aspect of the stack depth limit issue is described in #3222 (inability to remove local variables from the stack). Another aspect is that Solidity does not allow the user to specify whether a variable should be stored in memory or on the stack. However, it is often useful for the programmer to be able to specify where to put variables (primarily due to the stack depth limit).

I'm making this issue to, first, ask whether this was an intentional design decision -- if so, why? -- and second, to propose that a mechanism to put local variables in memory be added to Solidity.

For reference, in Serpent, the programmer could specify where local variables would be stored as follows:

x = 5 # puts x in memory
with y = 2: # puts y on the stack

In Solidity, the memory keyword might be a natural way to implement this. For example:

uint256 memory x = 5; // puts x in memory
uint256 y = 2; // puts y on the stack
@axic
Copy link
Member

axic commented Jul 28, 2018

This should be relieved now by that fact that with C++ scoping variables are freed at the end of their scopes. This creates the option to have sub blocks for short lived variables.

However, the proposal here still stands and is valid. The feature however is more costly than using the stack.

@axic axic added feature language design :rage4: Any changes to the language, e.g. new features labels Jul 28, 2018
@github-actions
Copy link

This issue has been marked as stale due to inactivity for the last 90 days.
It will be automatically closed in 7 days.

@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Feb 14, 2023
@github-actions
Copy link

Hi everyone! This issue has been automatically closed due to inactivity.
If you think this issue is still relevant in the latest Solidity version and you have something to contribute, feel free to reopen.
However, unless the issue is a concrete proposal that can be implemented, we recommend starting a language discussion on the forum instead.

@github-actions github-actions bot added the closed due inactivity The issue/PR was automatically closed due to inactivity. label Feb 21, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed due inactivity The issue/PR was automatically closed due to inactivity. feature language design :rage4: Any changes to the language, e.g. new features stale The issue/PR was marked as stale because it has been open for too long.
Projects
None yet
Development

No branches or pull requests

4 participants