Hacker News new | past | comments | ask | show | jobs | submit login
Why you don't need the Y combinator in Perl 6 (perlgeek.de)
26 points by DanielRibeiro on Dec 29, 2010 | hide | past | favorite | 6 comments



Yeesh, the power of language to obfuscate never ceases to amaze me. The power of "anonymous functions" is not in failing to give them a name, it is in your ability to just create one in the flow of another function and have all the mighty power of closures. The anonymity is, in the grand scale of things, quite incidental.

I wouldn't say this except for how people go ballistic if their "anonymous functions" aren't supported in a language that has everything else you need. That's silly. You don't need the YCombinator in Perl 5 or Perl 6 because "my $func; $func = sub { $func->(...) }" is perfectly fine.

In other news, the importance of "asynchronous" is that it doesn't block, not that you've manually chopped it up into a lengthy stream of event handlers. If it doesn't block, it doesn't block, even if the code on first impression looks like blocking code but in fact the runtime takes care of the continuation transform for you. (Also I can rant about how the word "immutable" gets misinterpreted and cargo-culted but that would be a lengthier post.)


(Also I can rant about how the word "immutable" gets misinterpreted and cargo-culted but that would be a lengthier post.)

Please do.


how can I use this when coding mutually recursive functions?


Like jerf said, just give them a name and be done with it. Why would you want anonymous, mutually recursive functions?

These things are sometimes useful in writing compilers though, but then the transformations are more elaborate.


You also do not need it in JavaScript.

  var x = function y() {
     ...
     y();
     ...
  }
'y' is only bound within the function and allows the function to refer to itself. I.e. you can have anonymous, recursive functions, which is useful in "memberfunctions".

Actually the more common

  function f() {}
is identical to

  var f = function f() {}
and not

  var f = function() {}
Edit: Of course there's also arguments.callee...


The more things change the more they stay the same.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: