Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: getting rid of special features

by moritz (Cardinal)
on Feb 17, 2013 at 15:39 UTC ( #1019152=note: print w/ replies, xml ) Need Help??


in reply to Re^2: getting rid of special features
in thread getting rid of costly special features

actually I don't wanna get rid of the feature but of the syntax.

Then we are (mostly) in violent agreement.

I still think that ++ being special-cased for strings is a rather harmless example, and there is another argument for keeping it: It's nicely symmetric with how ranges of strings work:

$ perl -wE 'say for "a".."e"' a b c d e

which might be used a bit more often than direct increment on strings.

Now that we've already having this discussion, I'd like to point out some more Perl 5 features that could be reworked to much saner:

  • The flipflop (.. operator in scalar context) could have its own operator, making accidental usage of ranges in scalar context much less confusing
  • reverse should lose its magic dual functionality (list reversal vs. string reveral) depending on context. Perl 6 uses another function for string reversal (flip), but other approaches are possible too.
  • Whitespace is allowed between sigils and the name of the variable. There's no good reason to keep that.
  • Indirect method call syntax. (This one is hard to remove).
  • The control sequences for newish regex features are really obscure and hard to remember.

But in the long run, removing cruft is only a small part of evolving Perl 5. I firmly believe that in order to stay competitive, it needs a type system(*), proper subroutine signatures and a less bare-bones OO system in core.

(*) If the need for a type system isn't obvious to you, let me just tell you that at least 95% of all the character encoding trouble in Perl 5 could easily be avoided by having separate types for text strings and byte buffers.


Comment on Re^3: getting rid of special features
Download Code
Re^4: getting rid of special features
by johngg (Abbot) on Feb 17, 2013 at 18:26 UTC
    $ perl -wE 'say for "a".."e"' a b c d e

    It had never occurred to me before seeing a range in the context of this thread to try

    $ perl -wE 'say for q{x} .. q{ac};' x y z aa ab ac

    Perl has me laughing out loud with amazement and delight sometimes :-)

    Cheers,

    JohnGG

      However, sort order is different from "range order"...
        > However, sort order is different from "range order"...

        So what?

        DB<125> sort 1..12 => (1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9)

        Lexicographic sort is always different!

        Cheers Rolf

Re^4: getting rid of special features
by LanX (Canon) on Feb 17, 2013 at 20:06 UTC
    > It's nicely symmetric with how ranges of strings work:

    yes and no!

    DB<115> $a="aa"; print --$a -1

    that much about orthogonality in Perl. :(

    Cheers Rolf

        I meant yes (ranges) and no (decrement)

        The symmetry between integers and strings is broken.

        Cheers Rolf

Re^4: getting rid of special features
by LanX (Canon) on Feb 17, 2013 at 20:15 UTC
    > But in the long run, removing cruft is only a small part of evolving Perl 5. I firmly believe that in order to stay competitive, it needs a type system(*), proper subroutine signatures and a less bare-bones OO system in core.

    actually typing a scalar my int $a would make translating $a++ very easy and giving another approach to solve this.

    Cheers Rolf

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2015-07-05 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls