Update: 11/13/2018 release was released , here is a detailed description of the changes. The article tells about the status of this version in May (five months before the release).
I want to talk about the changes in the Solidity language, which are expected in version 0.5.0. Immediately, I note that I will confine myself only to the language — its grammar and semantics.
There is no imputed text on this topic even in English, but recently a project appeared in the Solidity repository.
On it you can track the progress of preparation of version 0.5.0.
Disclaimer: the article describes the current state of the project, a lot can be changed for release. Exact information can be obtained from the official changelog'a .
Solidity has accumulated quite a lot of outdated constructions that I would like to remove from the language, but this still cannot be done due to backward compatibility. This category changes:
throw in favor of revert() / assert(...) / require(...) . The transaction rollback mechanism is different from the exception mechanism, and I want to emphasize this difference at the language level.var , which, taking into account the rules of type inference, easily leads to errors, for examplefor(var i = 0; i < 100500; i++) { ... //var (z, y, z) = foo();constant for functions - everywhere should be view or pure.gasleft() instead of msg.gas . So it is clear that this is not some kind of constant, but the remaining amount of gas. Yes, gasleft() can be overridden.block.blockhash to blockhash . It is logical, because the blockhash current block is not available ( block.blockhash(block.number) == 0 ).0xaf days .sha3 suicide / sha3 in inline assembly.x=+1; instead of x+=1; ).years multiplier, because now it is defined as 365 days , and this is not very closely related to the usual calendar. It seems to me a controversial decision - it would seem, as long as you can limit yourself to a warning.In Solidity, very different constructs have a similar syntax. This makes it difficult to read the code, but it even more spoils the life of developers of tools for working with source codes (this applies to the compiler as well). It's nice to see that work is being done in this direction too.
emit keyword when generating events .constructor(<args>) public { ...public or internal , cannot be view or pure , cannot have return values, i.e. is a special entity. x = 1; revert(); uint x; }``` --strict-assembly compiler option. It has limited stack manipulation and inaccessible labels and transitions - instead of them it is proposed to use more familiar control structures like for or switch .0x0 use address(0) .struct A {} ). Not really wanted, but before the grammar is allowed.With visibility modifiers was an easy mess, largely due to the presence of default values. There are a lot of minor edits that should make the language more stringent, removing this confusion.
And since these modifiers fall into the ABI contract, the changes affected him too.
external view functions using public variables.In Solidity, there are several functions that take any number of arguments, glue them together into one binary sausage and continue to work with it. In this process, many subtleties and unobvious moments, and now decided to deal with them.
abi global object and its methodsencode , encodePacked , encodeWithSelector and encodeWithSignature , allowing you to control the assembly of data for a call or hash.keccak256 / sha256 / ripemd160 and call / delegatecall with their help. It is planned to change the syntax of these commands so that they could not take an argument list of arbitrary length.keccak256(1) it is now not the least sufficient type ( uint8 ), but uint256 . If this behavior does not suit you, you will have to use explicit type keccak256(uint8(1)) ).var and the high (albeit finite ) accuracy of computing constant expressions.msg.data length at the EVM level.In quotes, because it basically is about "unexpected" access to storage without using assembly.
<array>.length .delete array for a long time, there is delete , for reducing the size, it is proposed to use pop() , in addition to this, operations like truncate() and extend() are discussed. Well, there is still an assembly, if you really need to.In any barrel of honey will have its own fly in the ointment.
revert , assert and require in this list, but from the grammar point of view they remain just functions (and they can be overridden).There are several very important changes that do not directly affect the language, but they will greatly affect the code of new contracts.
Although the release date is still unknown, many innovations can already be touched.
They are enabled usingpragma experimental "v0.5.0";
andpragma experimental "ABIEncoderV2";
The compiler, of course, gives a warning.
Overall, 0.5.0 is perceived positively. They will remove something that cannot be eliminated due to backward compatibility, they will tightly fix a couple of slippery topics and make several useful changes. Then we'll wait for refactoring of inheritance , and there, maybe, Vyper will arrive in time.
Source: https://habr.com/ru/post/353306/
All Articles