Pointers and references: Difference between revisions

m
→‎{{header|Raku}}: Fix comments: Perl 6 --> Raku
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
m (→‎{{header|Raku}}: Fix comments: Perl 6 --> Raku)
Line 1,525:
=={{header|Raku}}==
(formerly Perl 6)
In Perl 6Raku all non-native values are boxed and accessed via implicit references. (This is like Java or Python, but unlike C or Perl 5, which use explicit referencing and dereferencing.) Variables are references to containers that can contain references to other values. Basic binding (aliasing) of references to names is supported via the <tt>:=</tt> operator, while assignment to mutable containers implies a dereference from the name to the container, followed by copying of values rather than by duplicating pointers. (Assignment of a bare object reference copies the reference as if it were a value, but the receiving container automatically dereferences as necessary, so to all appearances you are putting the object itself into the destination rather than its reference, and we just think the object can be in more than one place at the same time.)
 
<lang perl6>my $foo = 42; # place a reference to 42 in $foo's item container
Line 1,542:
References to hashes and functions work more like arrays, insofar as a method call acts directly on the container, not on what the container contains. That is, they don't do the extra dereference implied by calling a method on a scalar variable.
 
To the first approximation, Perl 6Raku programmers do not think about references much; since everything is a reference, and value semantics are emulated by assign and other mutating operators, the ubiquitous references are largely transparent to the Perl 6Raku programmer most of the time.
 
=={{header|REXX}}==
2,392

edits