|
|
|
|
|
by ryl00
1889 days ago
|
|
This is one part (of many) of perl that I like, that it exposes the pointer-y parts to the programmer (to abuse :)) # hash
my %a = ( 'one' => 1, 'two' => 2 );
my %b = %a;
$b{ 'two' } = 99;
# prints 2
print $a{ 'two' }, "\n";
# reference to hash
my $a = { 'one' => 1, 'two' => 2 };
my $b = $a;
$b->{ 'two' } = 99;
# prints 99
print $a->{ 'two' }, "\n";
|
|
Most dynamic languages expose the data as references. In fact, the one thing that trips up JavaScript developers (especially in React) is that they do not understand how references work. I see senior and lead developers inadvertently doing mutation all the time. Or getting incredibly paranoid that two identical strings, for example, do not equal each other in the strictest sense in JS. They also throw in memoization everywhere due to their fundamental lack of understanding.
You can always tell the developers that do not have C/C++/Pascal experience.
[1] https://en.wikipedia.org/wiki/Sigil_(computer_programming)