Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Reference in Perl 6

by moritz (Cardinal)
on Aug 20, 2010 at 07:01 UTC ( [id://856193]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Reference in Perl 6
in thread Reference in Perl 6

Why do people always assume the worst, and place no confidence whatsoever in the language design team?

Of course we've worked hard to make the design as non-uniform and counter intuitive as possible</sarcasm>

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^4: Reference in Perl 6
by Anonymous Monk on Aug 20, 2010 at 13:29 UTC

    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.)

      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.
        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!

Re^4: Reference in Perl 6
by Anonymous Monk on Aug 20, 2010 at 11:00 UTC
    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.

      You could have helped at any time. Still can.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://856193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found