Skip to content

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

Closed as not planned
@tinybike

Description

@tinybike

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed due inactivityThe issue/PR was automatically closed due to inactivity.featurelanguage design :rage4:Any changes to the language, e.g. new featuresstaleThe issue/PR was marked as stale because it has been open for too long.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions