in reply to Re^6: Reference in Perl 6
in thread Reference in Perl 6
So, everything except arrays and hashes? Is "$foo" in "my $foo = 'hi'" a reference?
$foo is variable. If you do a
my $foo = Something.new();
then the newly created object is stored by reference in the variable. It's the same for string literals, but since strings and immutable (and so-called "value types"), it doesn't make a difference for strings.
How would I create an alias (a reference) to a sub?
sub foo($x, $y) { say $x ~ $y } my $foo_ref = &foo; # leaves $foo_ref writable my $foo := &foo; # basically the same, but you can't # assign to $foo afterwards # passing values to a signature is a form of # binding too, so this works: sub c(&func) { func(42, 23); } c(&foo); c($foo); c($foo_ref);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Reference in Perl 6
by Anonymous Monk on Aug 20, 2010 at 16:42 UTC | |
by moritz (Cardinal) on Aug 23, 2010 at 12:10 UTC | |
by Anonymous Monk on Aug 23, 2010 at 18:19 UTC |