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

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

perl -E 'say substr ("Hello World!", 5);'
  • Comment on Re^5: More comprehensive style guide for Perl docs than perlpodstyle?
  • Download Code

Replies are listed 'Best First'.
Re^6: More comprehensive style guide for Perl docs than perlpodstyle?
by Veltro (Hermit) on Jan 07, 2019 at 15:03 UTC

    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)).

        You keep saying that the split function needs fixing, but I don't see why. During the entire time that I have been using Perl, never have I encountered one situation that I was not able to use the split function to split anything. So instead of spreading this nonsense about how broken things are in your opinion, maybe you can ask questions regards the issue you are trying to solve instead. You can ask any question by providing some example with something that you are trying to accomplish and people here will most happily try to provide you with some answers.

        Now you mention Python: First of all it seems that there are actually two split functions: split and re.split. Second of all the prototype of the latter function is almost exactly the same as in Perl: re.split(pattern, string, maxsplit=0, flags=0). There is no use of a dictionary with named arguments, so what are you actually saying? As a matter of fact there is one more argument as in Perl, but in Perl this flag is nicely incorporated in the regular expression. Third, Python introduces many other functions as re.findall to make the language more versatile.

        So, I ask you, what is it exactly that Guido has fixed?