Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Perl6 headaches?

by rchiav (Deacon)
on Nov 04, 2001 at 22:19 UTC ( #123206=note: print w/replies, xml ) Need Help??


in reply to Perl6 headaches?

Well I'm not sure if I'm going to change your mind but I think there's a lot of reaons to change the notation. I don't think you can pick any one reason and have it stand on it's own.

There's quite a bit that's changing with respect to array/hash refs and changing how they are accessed fits into that. It could be done withtout changing -> to . but with the other reasons, it fits. From Exegesis 2:

Access through... Perl 5 Perl 6 ================= ====== ====== Scalar variable $foo $foo Array variable $foo[$n] @foo[$n] Hash variable $foo{$k} %foo{$k} Array reference $foo->[$n] $foo[$n] (or $foo.[$n] +) Hash reference $foo->{$k} $foo{$k} (or $foo.{$k} +) Code reference $foo->(@a) $foo(@a) (or $foo.(@a) +) Array slice @foo[@ns] @foo[@ns] Hash slice @foo{@ks} %foo{@ks}
Now other reasons..
1) To me dot notation will be much less cluttered than -> when you have a lot of complex data structures and OO structures that go fairly deep. Using Perl for little over a year, my biggest complaint with the language is just how ugly the code gets when you deal with complex data structures and OO. I think dot notation will help.

3) It really doesn't need to be used for derefrencing, just for OO.

2) Just about every other language that supports OO uses dot notation (could be all, but I'm covering my bases). It takes away a reason not to use Perl.

3)Perl is going to have much better OO functionality. It's not just going to be something that's hacked on top of what's already there (like now).

4) It's one less character

And you probably still don't like it. Maybe because I haven't been around that language that long, but I personally like the change. In a year or so, I'd bet it's no longer an issue.

Rich

Replies are listed 'Best First'.
Re: Re: Perl6 headaches?
by chromatic (Archbishop) on Nov 05, 2001 at 01:08 UTC
    I agree. This is a change made for the sake of consistency. I'm not a big fan of the underscore, but I can see the point. Overloading '+', like Java does in its String class wouldn't work -- not with magical DWIM scalars. (No snide remarks about Java's consistency here, either :).

    The dot operator isn't just for OO -- it'll be used to access properties and attributes as well. Sure, you could argue that it's syntactic sugar for lvalue subs, but I like sugar, in measured doses. It'll be used commonly, and one character is shorter than two. It'll probably be easier to read, too, because the dot is small.

    I'll personally have a bit of trouble with the sigils becoming part of the variable name, instead of indicating what to expect. Then again, consider how many new programmers make context errors like @array[1] = localtime;.

    It's change, yeah, but it's not for the sake of change. It's for the sake of consistency, Perlishness in general, and the principle that Perl should Just Make Sense. I'll miss the dot concatenation operator, but I'm willing to spend the 30 seconds it takes to learn a few new operators. In the long run, this is a good change.

      Overloading '+', like Java does in its String class wouldn't work -- not with magical DWIM scalars.

      Personally, I was more disappointed with using '_' instead of '+' than I was with using '.' instead of '->'. (FWIW, I don't understand WYM w.r.t. DWIM scalars.)

        DWIM scalars: ie, the fact that numeric strings convert themselves to numbers in numeric context, and that numbers convert themselves into strings in string context. Overloading '+' for strings would break this behaviour; and I think pretty much everyone can agree that this is a Bad Thing. :-)

        (Eg, what if you add a numeric string and a number together... Should they be concatenated, or added?)

        bbfu
        Seasons don't fear The Reaper.
        Nor do the wind, the sun, and the rain.
        We can be like they are.

Re: Re: Perl6 headaches?
by jepri (Parson) on Nov 05, 2001 at 02:03 UTC
    Personally I found the variable notation to be one of the more 'exotic' things about Perl. I rather like exotic things. It was neat that the variable character told Perl how to treat what you were extracting, rather than telling Perl about the container that held it. However I agree that it can get a bit hairy when you get to code like @{$thing[$c]}[$b].

    I personally think Perl is losing a little of it's syntactic mystique, but from the sound of it we are getting a more magical engine, so it should still be fun. And ultimately, that's why I've stuck with Perl despite all the times I've tried to wean myself onto Eiffel, Java, etc.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2021-09-17 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?