Sorry, I didn't mean to assume the worst. Refs seem like they might be subtly different in Perl 6, but there's no perldoc perl6reftut to fill in the details. Also, note that I did write: "What is the uniformity of the design that I don't yet see?"
I think there will be a lot less uncertainty bouncing around once the perldocs are in place. Then when someone says, "Um, I dunno, this particular feature/aspect looks weird -- I don't understand it and it makes me nervous", instead of directing them to the rather dense Synopses or telling them not to worry the design team has done a good job, you can just point them to the relevant self-contained friendly perldoc. :)
(BTW, although there seems to be a lot of anon monks here, this is only my 2nd post in this thread.)
| [reply] [Watch: Dir/Any] |
Sorry, I think I have over-reacted.
As I wrote before, everthing is a reference - except containers typed as native types, which exist for speed reasons (but aren't implemented in any compiler yet).
The typical use cases for explicit references in Perl 5 were nested data structures, creating aliases, and changing remote data.
For the former, you don't need any references in Perl 6 - you can simply insert a hash or array into an hash or array. In Perl 6, the question of whether a construct flattens into a list is orthogonal to references, and is mostly a syntactic distinction.
Aliasing is now done via binding, $a := $b aliases the variables $a and $b. Importing subroutines uses that mechanism under the hood.
Changing data that came in from somewhere else is done by an assignment, and the container is marked as is rw, for example
sub swap($a is rw, $b is rw) {
($a, $b) = ($b, $a)
}
Object attributes also can have the is rw trait.
(People also sometimes say that a Capture is something like a fat reference, but I disagree; it is just a type of object that can hold other objects, and isn't different from user-defined types in that way, so I'm not going to elaborate on them).
Is there anything else you need to know for a coherent picture of references?
Perl 6 - links to (nearly) everything that is Perl 6.
| [reply] [Watch: Dir/Any] [d/l] [select] |
As I wrote before, everthing is a reference - except containers typed as native types,
So, everything except arrays and hashes? Is "$foo" in "my $foo = 'hi'" a reference?
Aliasing is now done via binding,
How would I create an alias (a reference) to a sub? Like this?:
sub foo($x, $y) { say $x ~ $y; };
my $foo_ref := foo; # ?
Thanks for the help. It looks like you have the beginnings of a perl6reftut here!
| [reply] [Watch: Dir/Any] [d/l] |
Why do people always assume the worst, and place no confidence whatsoever in the language design team?
The reasons are the history of the project and its implementations. They don't leave much confidence.
| [reply] [Watch: Dir/Any] |
| [reply] [Watch: Dir/Any] |