localtime Monks

I stumbled over pugs via the Perl 6 mailing list yesterday. As I had all the prerequisites installed I fetched the darcs repository and compiled it on my XP box at work.

I attempted the following on my windows command line:

C:\dev\fun\pugs>pugs -e "sub hi { \"Hello, \" ~ $_ } ; hi( \"Perl 6!\n +\" )"

This gave me my very first working Perl 6 script! Wohoo! It also gave me the syntax-tree of the one-liner.:

*** Evl: Syn ";" {{ Syn ":=" {{ Var "&prefix:hi" (line 1, column 8); s +ub {...} } }; App "&prefix:hi" [] [Val (VStr "Perl 6!\n")] }} *** Evl: Syn ":=" {{ Var "&prefix:hi" (line 1, column 8); sub {...} } +} *** Ret: sub {...} *** Evl: App "&prefix:hi" [] [Val (VStr "Perl 6!\n")] *** Evl: Syn "[]" {{ Syn "," {{ "Perl 6!\n" }}; 0 }} *** Evl: Syn "," {{ "Perl 6!\n" }} *** Ret: ("Perl 6!\n") *** Ret: ("Perl 6!\n") *** Evl: Syn "[]" {{ Syn "," {{ "Perl 6!\n" }}; (1, ...) }} *** Evl: Syn "," {{ "Perl 6!\n" }} *** Ret: ("Perl 6!\n") *** Ret: () *** Evl: Syn ";" {{ App "&infix:~" [] [Val (VStr "Hello, "),Var "$_" + (line 1, column 22)] }} *** Evl: App "&infix:~" [] [Val (VStr "Hello, "),Var "$_" (line 1, +column 22) ] *** Evl: Var "$_" (line 1, column 22) *** Ret: ("Perl 6!\n") *** Evl: Syn "[]" {{ Syn "," {{ }}; (0, ...) }} *** Evl: Syn "," {{ }} *** Ret: () *** Ret: () *** Ret: "Hello, Perl 6!\n" *** Ret: "Hello, Perl 6!\n" *** Ret: "Hello, Perl 6!\n" *** Ret: "Hello, Perl 6!\n" Hello, Perl 6!

Dandy! But I couldn't stop yet. I dug up Featherweight Perl, which had some examples translated from "A gentle introduction to Haskell" (which is, I have to admit, not very gentle). This is where I hit a wall. The following code:

multi sub quicksort () { () } multi sub quicksort ( $x, *@xs ) { @xs.grep( { $_ < $x } ).quicksort, $x, @xs.grep( { $_ >= $x } ).quicksort } quicksort(1,5,2,4,3)

Produces a listing that to me is quite puzzling:

C:\dev\fun\pugs>pugs ex.pl Fail: cannot cast: VError "\nunexpected \")\"\nexpecting term" (NonTer +m (line 1, column 27))

It looks like the parentheses that specify the return value of the function with the empty list arrives as a surprise. I have no idea why this happens, and while I do know that pugs is in flux I'm curious if someone can explain what's going on. I looked at the pugs code, but my Haskell-fu is very weak, so that didn't help me much. (One day, Haskell, I shall master your curried Monads!)

Anyhow. It was a fun little experiment, and it's great to see initiatives like this. Kudos to Autrijus Tang.

pernod
--
Mischief. Mayhem. Soap.


In reply to Hello Perl 6. Running pugs on Windows by pernod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.