Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: Prototype like sort()?

by LanX (Saint)
on Feb 01, 2018 at 17:23 UTC ( [id://1208261]=note: print w/replies, xml ) Need Help??

in reply to Re: Prototype like sort()?
in thread Prototype like sort()?

Others explained that not all builtins' APIs can be copied by using prototypes.

But if you are willing to combine your rank with another modifier sub like by with prototype, you could form compound statements like

rank LIST; rank by BLOCK LIST; rank by {SUBNAME} LIST;

I find this more readable than your original approach.

If acceptable, I could elaborate further on a clean implementation.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Prototype like sort()?
by perlancar (Hermit) on Feb 05, 2018 at 05:14 UTC
    That's nice, I got reminded of TOBYINK's PerlX::Maybe when reading that code. But it's too "magical" for my taste. Thanks for the offer though.
      Actually, as long as we are only talking about two variants, it's more sensical to just define a second rankby .

      IMHO a module with many sort like functions would profit from a specialized by .

      > But it's too "magical" for my taste.

      In context of my DSL mediators I've already put some efforts into investigating possible pitfalls and found very good solutions.

      Please note that most other solutions come with ugly edge cases which are excluded here.

      There is a performance penalty though ...

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Wikisyntax for the Monastery

        I invite you to create a fork that employs this interface, and let's see which interface users like more (we'll have to wait for some time though ;-).

        You are also welcome to send me a pull request, although I cannot promise that I'll accept it.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-06-13 00:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.