0.0684 s - время 43 - запросов

We use cookies in order to improve your experience while using our website. If you continue to use our site, you accept our Cookies Policy, revised Privacy Policy and updated Terms of Use.

BTC $ 12968.8606065 (2.2 %)
ETH $ 310.728580017 (-1.9 %)
XRP $ 0.3948947274 (-2.24 %)
BCH $ 417.206439811 (-1.89 %)
LTC $ 118.863583399 (-3.4 %)
EOS $ 5.8580554873 (-2.46 %)
BNB $ 31.8970974961 (-4.93 %)
USDT $ 0.9998418267 (-0.57 %)
BSV $ 203.534927004 (-2.65 %)
TRX $ 0.0337806644 (-1.16 %)

Details Of Solidity 0.5.0 Update With Respect To Variables

20:00 27/03/2019
Details On Solidity 0.5.0

Introduction

 

Solidity updates can be big or small. Either way, they bring changes both to the existing environment and planned projects. We have already examined some important details on particular updates related to struct components and functions visibility. Still, there are many other interesting questions left.

 

As it was mentioned in previous articles devoted to Solidity, all Solidity updates may be divided into several categories and relate to different components.

 

In terms of categories, these changes are:

 

  • Top language changes;
  • Updates that are crucial for the code;
  • Updates related to language features;
  • Updates related to compiler features;
  • Bug removal.

 

In terms of components, these changes are associated with:

 

  • Changes in language semantics and syntax;
  • Explicitness management;
  • Unnecessary component removal;
  • The management of contract interoperability.

 

In this article, we will talk about changes regarding variables. Since variables are the smallest components of a smart contract, their modification can be attributed to the first three categories and any of types. A more detailed classification is impossible without a specific example.

 

Changes In Variables Introduction

 

The first change we are going to talk about concerns the way variables are introduced in a contract. The change statement itself looks like this:

 

The var keyword is now disallowed to favor explicitness.

 

 

So what does it mean? Basically, there are two ways of creating new variables in the programing language. The first way presupposes that there should be a keyword before the variable declaration section. For example, this approach is used in the Pascal language. In order to create new variables, one needs to enter “var” and then specify their list.

 

The second change presupposes that there is no special declaration word. This means that new variables are introduced in any place of a program. Each unknown word will be automatically checked for syntax and defined by the compiler as a variable, a function, or any other program component.

 

Let’s compare these two examples:

Changes In Variables Introduction

Previously, it was possible to declare variables in Solidity in both ways. We can see this in the previous language versions. Such a mixed approach can confuse developers, it takes free space in the code and requires additional code processing. Eliminating such redundancy improves the quality of the code.

 

Change In Storage Variables

 

The second change is about storage variables. There are several different areas where developers can store variables data. The most crucial one is the contract storage area. It takes place on blockchain. Thus, any possibility of clearing unnecessary memory load is positive.

 

The change statement is:

 

Uninitialized storage variables are now disallowed

 

What does this mean? In general case, it is possible to create a variable without giving a value to it. This means that you reserve the name and space but the variable doesn’t participate in program execution yet. When it comes to temporary memory, it doesn’t matter how much variables exist. But in the case of blockchain memory or contract execution memory, this plays a great role.

 

Removing the option of variables introduction eliminates unnecessary reservation of empty space.

 

Afterword

 

The above examples of changes in the Solidity language are important ― they are responsible for saving space and increasing clarity. However, such an actively developing language may reverse them in the future. Other interesting changes include tuples management, arrays, and assignment issues. We are going to talk about them in our next articles.

Found a mistake? Highlight it and press Ctrl + Enter to notify the administrator.

Up-to-date Blockchain and cryptocurrency news. Be the first to know!

What is it for?