About variables in programming2 July, 2019
If you look at Wikipedia, you can see that a variable in programming is a named, or otherwise addressed, area of memory whose address can be used to access data. The word from this definition to which I would like to draw your attention is data. Is it really so that in the programming languages in which we write, variables are used only for accessing data. In fact, in addition to data access, variables are also used to access objects (instances of classes) and arrays (associative and ordinary) and some other things. Data (strings, integers, floating-point numbers, boolean values), objects (instances of classes), and structures for a person are essentially different entities (abstractions), and it would be reasonable, for example, in programming languages with static typing, to handle them as with different things, ignoring the fact that for the machine they are the same (named memory areas). To do this, instead of variables, we can begin to use such entities as, for example: object, structure, data. The following example uses PHP syntax, but this replacement of variables with new entities will take place only in languages with static typing.
When I came up with this, I wanted to create an RFC for PHP to try this replacement in it. But soon, after a discussion on hubr.com, I realized that this would only happen in languages with static typing. Since I do not write in such languages, until I can try to introduce this innovation anywhere.
//If formerly, for example, to store objects in PHP, we used variables that are declared in the current syntax using the $ symbol $objectVar = new SomeClass(); //Now for the objects we will have a special entity “object”, which, for example, will be declared using the # symbol ^objectEntity = new SomeClass(); //"Structure" entities will be declared using * symbol *simpleArray = ['one', 'two', 'three']; *associativeArray = ['key' => 'val', 'another_key' => 'another_val']; //And "data" entities using symbol % %string = 'abcde'; %integer = 123; %floating = 1.23; %boolean = true;