Re: Justification for the "reversed" instruction format
[email protected] (Trey Harris) Thu, 08 Sep 2016 18:41:46 +0000
| Newsgroups | perl.perl6.language |
|---|---|
| Message-ID | <CALKJ+Et4Py=ysdf8KSshcwd7k6ZUWNiBn8b7H9YLCQQ-3PfFCA@mail.gmail.com> |
On Thu, Sep 8, 2016 at 9:23 AM Aaron Sherman [email protected] <http://mailto:[email protected]> wrote: I don't know Haskell, but isn't flip just: > > sub flip(&f) { -> $b, $a, |c { f($a, $b, |c) } } > > And then: > > perl6 -e 'sub flip(&f) { -> $a, $b, |c { f($b, $a, |c) } }; my &yas = flip > &say; yas(1,2,3)' > 213 > > Yes—but my worry about that was that it wouldn’t carry over signature constraints and coercions as a specific argument-flipper sub written with the same signature (flipped). Haskell does deep type inference, unlike Perl 6, so simply writing flip f x y = f y x is sufficient to get exactly the same behavior in constrained or coercive contexts. > Aaron Sherman, M.: > P: 617-440-4332 Google Talk, Email and Google Plus: [email protected] > Toolsmith, developer, gamer and life-long student. > > > On Wed, Sep 7, 2016 at 6:13 PM, Brandon Allbery <[email protected]> > wrote: > >> On Wed, Sep 7, 2016 at 6:08 PM, Parrot Raiser <[email protected]> wrote: >> >>> There is a "flip" in P6, to reverse the characters in a string, and a >>> "reverse", to return the elements of a list. Would either of those be >>> an equivalent? >>> >> >> Not without an "apply" mechanism used for function / method / operator >> invocations. Which is almost viable in Perl 6 since the parameters get >> passed as a list --- except that the list is only visible within the >> implementation, not at the call site (which is what "apply" does). >> >> -- >> brandon s allbery kf8nh sine nomine >> associates >> [email protected] >> [email protected] >> unix, openafs, kerberos, infrastructure, xmonad >> http://sinenomine.net >> > >