Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Reference in Perl 6

by Anonymous Monk
on Aug 19, 2010 at 20:41 UTC ( [id://856122]=note: print w/replies, xml ) Need Help??


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

So references aren't gone; just their visibility has decreased drastically, as well as the need for explicit derferencing.

This comment fills me with dread. I understand Perl 5, where a reference is a reference, and if I want the thing it refers to, I manually de-reference. Simple enough. I've got that. (I also understand Python's way of doing things: every variable is always a reference, and the system de-references as necessary and everything just works.) But I don't like the sound of (Perl 6's) "their visibility has been decreased drastically". Are there many special cases where sometimes there's auto de-reffing and sometimes there isn't? What is the uniformity of the design that I don't yet see?

Replies are listed 'Best First'.
Re^3: Reference in Perl 6
by moritz (Cardinal) on Aug 20, 2010 at 07:01 UTC

    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.

      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.
      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://856122]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-29 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found