Re: => Lambda shorthand syntax

Ralph Ritoch <[email protected]>
Newsgroups gmane.comp.lang.pike.user,gmane.comp.lang.pike.devel
Message-ID <CABFWrWUTDohRcO9ppk10OagQbWMfhb3bTmvOpSVnHN-1Wh+_xA@mail.gmail.com>
Stephen,

Until this operator is ready you can use a macro to get close to the syntax
you want.

#define f(x, y ...) lambda(y) { return x; }

int main() {
   function y = f(x * y, int x, int y);
   write((string)y(5,2));
}

This was more for fun than practical use, but it demonstrates that the
operator should be fairly easy to achieve.

Best Regards,
  Ralph Ritoch




On Sat, Mar 14, 2015 at 6:59 PM, Stephen R. van den Berg <[email protected]>
wrote:

> Ralph Ritoch wrote:
> >I don't see it in the documentation but pike already has a syntax for
> >lambda expressions.
>
> Yes, it does.
>
> >Good luck with the pursuit for more operators.
>
> It's a new shorthand that makes certain common lambda expressions
> more readable (and is popular in other languages).
> --
> Stephen.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.