0.0461 s - время 42 - запросов

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 $ 8707.38256718 (9.42 %)
ETH $ 266.187011413 (7.15 %)
XRP $ 0.4089836315 (7.26 %)
BCH $ 432.746374396 (8.88 %)
LTC $ 113.393943851 (12.75 %)
EOS $ 6.9510723062 (10.4 %)
BNB $ 34.2780784824 (1.56 %)
USDT $ 1.0076898862 (0.44 %)
XLM $ 0.1326567565 (6.2 %)
ADA $ 0.0858852165 (8.27 %)

Solidity 0.5.0 Struct Update

08:15 01/03/2019
Solidity Language

Introduction

 

In this article we’ll continue the series of stories about Solidity updates. Solidity is a well-known programing language used in the Ethereum crypto environment. Its popularity is due to the fact that developers keep supporting it with regular updates. Obviously, such a responsible attitude doesn’t go unnoticed. The majority of smart contracts placed on the Ethereum blockchain are written in Solidity. Other languages also exist and are used as side solutions for specific cases. However, all of them — without exceptions — address the Ethereum Virtual Machine.

 

We have already examined one of Solidity changes that conserned functions visibility. This detail is important because it relates to vital interaction properties on blockchain. Still it is only one of the many changes applied to Ethereum within the 0.5.0 update.

 

Solidity updates can be of different size and importance. In this article, we will not examine two small updates released after January 22, 2019. However, it must be kept in mind that they might have changed something in the 0.5.0 update because they were introduced later.

 

Important 0.5.0 Changes

 

Before turning to our research, let’s recollect major details of the 0.5.0 update. In general case, each update contains changes that fall into the following categories:

 

  • breaking changes;
  • necessary code updates;
  • language features;
  • compiler features;
  • bug fixes.

 

In case of 0.5.0, the general number of influencing components is really huge. It also includes several blocks of changes, namely:

 

  • semantic changes;
  • semantic and syntax changes;
  • explicitness requirements;
  • deprecation section;
  • issues of contracts interoperability.

 

In our previous article, we explained functions visibility changes. Now let's discuss the key points of the “Variables” section. It contains several changes but only one on them is of the greatest interest to us today.

 

Empty structs

 

A struct is a component that unites several data elements under the same name. Basically, these elements can be of different nature depending on the language. As for Solidity, there may be variables only. Considering variables as non-divisible solid units, sometimes it is convenient to unite them.

 

Imagine a single point in the three-dimensional space. It has three coordinates to define its position — X, Y and Z. Separately, they don’t give any visual logical connection. Compare the following examples:

It has three coordinates to define its position — X, Y and Z

Variables on the left side of the table may be connected or not, while on the right side we see strong, underlined connection between them. Visually, this can be presented as three components that are separated or united in a container:

Empty structs

Containers application already had restrictions before the 0.5.0 update. But then another one was added. It states that no empty structs are allowed. This means that before the update, it was possible to declare a struct with no components inside. Thus the name of the struct became reserved. After the update, it is impossible to declare structs that have no elements inside.

Coordinate

The reason for this change is simple: clearance. Indeed, it might be a problem to have several reserved names with no application, especially when it comes to such space economical project as Ethereum.

 

Afterword

 

Variables are interesting to examine because they are the smallest bricks of any programming project. The way they are declared, assigned, managed and united into more complex components carries the general developers' aspiration. In our next articles, we will talk about other Solidity 0.5.0 changes.

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?