Into perl6 ( pugs )

lilstevey on 2006-09-08T08:39:10

  1. look around docs in pugs-win32\docs Find getting started - looks like a good place to start
    "(This is mostly just a skeleton with a few key URLs; feel free to flesh it out, improve the formatting etc.)"
    Oh well, still a good starting place, I'll dig a little more


  2. There is an articles directory - tpr.pod. I'll just pause to make "Open" pod files associatte with perldoc. The article is a very good guide.

    Double click pugs.exe, and a prompt!
    pugs> say "hello erf"
    hello erf
    bool::true
    pugs> 
    
    It may be simple, but its working perl 6 code.
  3. Further down the article now, it starts describing subroutene parameters - they look very nice, and also support defaults, named parameters and constraints via perl 6's type system. *splat* looks kinda cool too.

    everything seems pretty straightfoward until a "Lightweight closure syntax and the arrow operator" example - this appears a little foriegn at first sight:
    my $square = -> $x { $x * $x }; # use "->" to introduce args
    my @squares = map $square, 1 .. 10;
    
    I think, from reading the article futher that this means "taking in" so the above example says $square is a function, taking in $x, and the next line calls the square function using map, so that @squares is full of the following sequence 1,4,9 ... 100

    It strikes me that you need to know perl5 to get into perl6 at the moment - ineviatable I suppose, for the moment, but it may hamper adoption by a lot of people who didn't like perl 5 and didn't get into it for the very things that perl 6 fixes.
    This probably isn't high on @*todo though...

    Now its coming up to unicode operators, which is where pod on the terminal fails abysmally. Control codes just aren't as readable as there true forms.

    So falling back to the web, I try to find the original article, in a nice format so that I can see which unicode chars they are using. Casually flicking through the perl.com archives, I stumble across this article:



    Which is about topics, and includes a bit on the arrows above. ( -> doesn't require parentheses around its parameter list, and it topicalizes its first parameter ). After about a third of the way through it starts using a lot of perl 6 syntax that doesn't look that familiar, so I think I need to come back to this later.

  4. maybe its time to write a simple perl6 program and get it to run. I'll start with something simple, in the docs - an old fashioned "type in" if you will:
    +-------%< greeting.pl %<-----------------+
    # Script to display hello world

    "Hello World".say(); +-------%<-------------%<-----------------+

    C:\perl6>pugs-win32\pugs.exe perl6code\greeting.pl Hello World C:\perl6>
    Very Basic, but a start!

    And next:
    +-------%< squares.pl  %<-----------------+
    # Squares example

    my $square = -> $x { $x * $x }; # use "->" to introduce args my @squares = map $square, 1 .. 10;

    @squares.join("\n").say(); +-------%<-------------%<-----------------+

    C:\perl6>pugs-win32\pugs.exe perl6code\squares.pl 1 4 9 16 25 36 49 64 81 100 C:\Documents and Settings\Administrator\My Documents\perl\perl6>
So far no nasty spikes to discourage me from going back, and from reading the articles it does appear to be a very powerfull, expresive language.


Perl 5 expertise not required

Aristotle on 2006-09-08T13:17:48

It strikes me that you need to know perl5 to get into perl6 at the moment

What makes you say that? Anyone with knowledge of Smalltalk or Ruby or Lisp or the like (basically anything that has lists and closures) should be immediately familiar. In fact, they’ll have an easier time getting into the Perl 6 version, where you can specify a parameter, than the Perl 5 version, where you have to monkey with this bizarre $_ thing.

Conext of remark screwy

lilstevey on 2006-09-08T14:39:56

I should probably have been more carefull explaining the context of the remark - I was refering to what I perceived as the current state of documentation and articles about perl 6, rather than arrow operator or perl 6 in general.