Hacker News new | ask | show | jobs
by wantarray 4151 days ago
The author of that snippet was probably just trying to demonstrate multi-method dispatch using a familiar example; I don't think that's how people would actually calculate Fibonacci numbers in Perl 6.

I expect most would either use plain 'ol imperative code if that's what they're used to (from Perl 5), or do it with the sequence construction operator (triple dot):

  my @fib := 0, 1, *+* ... *;
...which looks funky on first sight, but is really just another operator.

From what I've seen so far, Perl 6 code is still similar to Perl code. Presentation snippets tend to focus on specific new features and should not be taken as representative samples of real-life code.

1 comments

I wrote the above snippet, but it was basically just one step beyond what Curtis Ovid Poe shows in his "Perl 6 For Mere Mortals" presentation.

My intention wasn't to make people say "wow, I know Perl 5 but now I'll never figure out Perl 6," but rather to illustrate some new features in the context of a familiar example. :) In fact, the above-mentioned presentation introduces P6 features by gradually expanding upon P5 code, showing that you can gradually grow into the language.