Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The * operator made me laugh out loud. Only Perl would have an operator called a "Whatever star".

Although, I actually think a lot of the stuff Perl does is really cool. I wouldn't want to have to maintain a codebase of it, but it never fails to be interesting. Like the whatever star. "*.value" basically saying, "Whatever value is here, gimme the value of it". It's different from a typical lambda declaration, but intuitive in its own way.



> It's different from a typical lambda declaration, but intuitive in its own way.

Isn't it pretty similar to Scala's use of "_"? I think _.value creates a one-parameter lambda in Scala.


Yeah, but it would be neat if it was a word instead, for example "that". "*" is hilarious, though. How do you multiply in Perl if the star is taken? I also like that it's named "whatever star", reminds me of Scala's Pimp my Library feature[0]

0: http://www.artima.com/weblogs/viewpost.jsp?thread=179766


An asterisk is only a Whatever if it's in term position:

    (* * *)(2, 3)
will happily print 6.


I'd like to point out there are magical errors put in to keep Perl6 code relatively sane too:

  > .map: ** * * * **
  ===SORRY!=== Error while compiling <unknown file>
  Multiple HyperWhatevers and Whatevers may not be used together


I didn't find the whatever star funny until this point.


Whatever ;)


Perl has always had something called "context" :)


Clojure has %:

(map #(/ % 2) [2 4 6 8]) => (1 2 3 4)

(map #(% 2) [#(- 2 %) #(* 2 %)]) => (0 4)

(#(+ %1 %2 %3) 2 4 6) => 12




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

Search: