Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Perl oddities

by dragonchild (Archbishop)
on Mar 01, 2005 at 14:09 UTC ( #435437=note: print w/replies, xml ) Need Help??

in reply to Perl oddities

Disambiguation messes with me. Once you have found something wonky, you put a + somewhere and Perl gets what you mean. Why a plus-sign?? I'm not adding a left-squiggly to shift when I do
sub foo { my $self = shift; $self->{+shift} = 3; return $self; }

Also, while we're talking about prototypes, why do some internals prototype and others don't? Can't the prototype for vec() look at how many elements there are in the array before bitching at me? And, I have to override CORE::GLOBAL::vec to eliminate the prototype. Overriding CORE::vec, even in a BEGIN block, isn't good enough. (Can you tell I don't like Perl's prototypes in any form?)

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^2: Perl oddities
by TimToady (Parson) on Mar 01, 2005 at 20:25 UTC
    There are several things wrong there that are fixed in Perl 6. You won't need the plus because you'll disambiguate autoquotes differently, so that a shift in curlies is always a real shift. And plus is always numeric in Perl 6--it's not a no-op as it is in Perl 5. But mostly, methods just look different. Your code might look more like this in Perl 6:
    method foo ($self: $key) { .{$key} = 3; return $self; }

    As for vec, that interface is a total kludge. You'll be much happier with real bit arrays, I expect.

Re^2: Perl oddities
by Anonymous Monk on Mar 01, 2005 at 16:11 UTC
    You aren't subtracting from a left squiggly when you put a minus in front of it either. It's not that + in this expression is special cased. Unary + in Perl is a noop. (Just like unary plus is a noop when doing arithmetic). In the example you give, putting a plus there is just one of the ways to do disambiguations. Putting parenthesis after shift works as well, as well as something else that's essentially a noop (adding an empty string for instance).

    I wouldn't call an idiom a Perl oddity - it's not part of the language itself, just an often used construct.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2019-11-22 07:43 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (110 votes). Check out past polls.