In most cases, languages ββwill not allow manipulating references to primitives. For instance:.
var a = 0; var b = a;
While manipulating non-primitives will result in manipulation of the state (sometimes destructive), which is reflected in all variables (using JS):
var a = []; var b = a;
It makes sense. I can fully understand why things like String.replace return a value instead of doing state manipulations.
I was interested, however, if there are no languages ββthat would allow primitives to manipulate states. For instance:.
var a = 0; var b = a;
I know the index in lower-level languages, and it almost does what I'm talking about, but I feel that it only resets the value, and not actually updates the link.
I also know about PHP links, but since PHP doesn't allow these things:
$str = "abcd"; $st[0] = "q";
In addition, when concatenating a series of lines in PHP, the $str .= 'var' loop is implied to create new lines for each iteration.
Maybe I'm crazy, even thinking about it, but with the increasing prevalence of object models as a background for variables, it seems that it can exist (it seems, in a way, it is insanely complicated, especially if you allowed int , but it seems like this syntax would be a good source of training).
source share