in reply to Re^3: More comprehensive style guide for Perl docs than perlpodstyle?
in thread More comprehensive style guide for Perl docs than perlpodstyle?

I would actually find that illogical. The function is called substr and not left (as soonix already indicates). So for me it is logic to provide a start and an end index. And personally I hate it when people create optional arguments somewhere in the middle of an argument list and so I love it how substr is defined.

  • Comment on Re^4: More comprehensive style guide for Perl docs than perlpodstyle?

Replies are listed 'Best First'.
Re^5: More comprehensive style guide for Perl docs than perlpodstyle?
by hippo (Archbishop) on Jan 07, 2019 at 14:29 UTC

    It is heartening to hear that you love it. OTOH, this just makes me sigh:

    perl -E 'say substr ("Hello World!", 5);'

      OTOH, then let's just build in a hash as eyepopslikeamosquito suggests:

      say substr ("Hello World!", { end-index => 5 } );

      If there is something that makes me sigh, then that is it. Say Good Bye to minimalistic code!

        I love minimalistic code. It's just that not everything can be minimalistic ... which is why Larry uses Huffman coding as a language design principle so that "things that are commonly used, or when you have to type them very often -- the common things need to be shorter or more succinct".

        I suggested named arguments for split not substr. For substr, I suggested having string slices built into the language (as Python and Ruby do).

        I'm not a language designer -- and splitting a string is a common operation -- so I'm sure there are better ways to fix split than my suggestion of named parameters. Unfortunately, in addition to being common, it's a lot more complex than substr. Designing a good split function is a hard problem. While Guido "solved" the problem for Python by dumbing down split, I see that perl 6 split handles the complexity by using "one of the :k, :v, :kv, :p adverbs" to control behaviour (update: I don't know what that means, later it says "A number of optional named parameters can be specified, which alter the result being returned" (including :skip-empty)).