You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change mapping syntax from var: map(key_type, val_type) to var: HashMap[key_type, val_type]
Motivation
Mapping syntax was changed in #564. While it made for easier understanding of how mappings work in practice, it precludes the use of the Python standard function map(fn, iter) -> iter for anything in Vyper to use. We propose adopting a MyPy-like type structure, which will make working with mappings (and nested mappings) more apparent, and open up the keyword map to future use as an iterator operation.
Specification
The syntax for mappings would change from var: map(key_type, val_type) to var: HashMap[key_type, val_type]. This looks like the following in practice:
structMyStruct: ...
my_mapping: HashMap[uint256, MyStruct]
my_nested_map: HashMap[bytes32, HashMap[uint256, address]]
@publicdeffoo():
self.my_mapping[1] =MyStruct({...}) # Same access as beforeself.my_nested_map[blk.hash][1] =msg.sender# Same access as before
Backwards Compatibility
This VIP will break the current syntax for defining mappings
Simple Summary
Change mapping syntax from
var: map(key_type, val_type)
tovar: HashMap[key_type, val_type]
Motivation
Mapping syntax was changed in #564. While it made for easier understanding of how mappings work in practice, it precludes the use of the Python standard function
map(fn, iter) -> iter
for anything in Vyper to use. We propose adopting a MyPy-like type structure, which will make working with mappings (and nested mappings) more apparent, and open up the keywordmap
to future use as an iterator operation.Specification
The syntax for mappings would change from
var: map(key_type, val_type)
tovar: HashMap[key_type, val_type]
. This looks like the following in practice:Backwards Compatibility
This VIP will break the current syntax for defining mappings
Dependencies
Depends on #564
References
No references
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: