http://www.perlmonks.org?node_id=11105854


in reply to Re^15: Ovid's take on the renaming of "Perl6" (updated)
in thread Ovid's take on the renaming of "Perl6"

Perl has the prototype (&) for code blocks but only as first argument. The rest of your rant is cryptic for me. - lanx
  • Comment on Re^16: Ovid's take on the renaming of "Perl6" (updated)

Replies are listed 'Best First'.
Re^17: Ovid's take on the renaming of "Perl6" (updated)
by Jenda (Abbot) on Sep 09, 2019 at 11:57 UTC

    Prototypes are best ignored.

    In Ruby, if you only need to pass one function/lambda/block/whatever-you-decide-to-call-it, you do NOT specify the function parameter in the method signature, you just happen to use the misnamed, absolutely illogical statement yield (or whatever concoction of vowels that word contains). There is no indication whatsoever in the signature that a block will be accepted as an unmentioned, unnamed parameter.

    As the parameter has got no name, you can't do something like testing it for null or undef, something that'd be in any way consistent with anything. Nope. You test the value of the block_given? method. How lovely.

    Now if you need to pass two lambdas ... you can throw all this down the drain and start again with a named parameter &whatever, call it with whatever.call. How do you specify the hailed blocks when calling that method I can't remember. What I do remember was that if you copied a block from one place to another, suddenly what used to introduce a new variable, lexical to the block, happily accesses a more global variable, 'cause variable declaration is too uncool and you are supposed to have a gazillion of two line methods anyway.

    Yes, you guess right. I had to use Ruby for some time and I hated every single minute.

    Jenda
    1984 was supposed to be a warning,
    not a manual!

      I think what LanX means when saying "prototypes" are formal subroutine parameters, like what Function::Parameters provides and what maybe becomes part of Perl 5.34, not what Perl currently implements under the name uf "prototypes".

      One of the main selling points of Ruby are Domain Specific Languages.

      Restricting Perl to have a code block prototype (&) only at first position is hindering many options for syntactic sugar.

      Be it more expressive versions of 'map' and 'grep' or 'loop' constructs. Basically because you want to add a modifier between keyword and block, without needing to explicitly introduce ', sub' .

      Your rant about the limits of Ruby may be legit, but had little or nothing to do with what I said or meant.

        If you add too much sugar, you end up with diabetes.

        The resulting syntax would be too confusing. "Is that thing a block or a hash?"

        I was reacting to your "better code blocks" and your mention of Ruby. Ruby doesn't have better code blocks. It has a highly confusing, hard to extend, misdesigned, misbehaving nonsense.

        Jenda
        1984 was supposed to be a warning,
        not a manual!