pernod has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
It now works. :)
by audreyt (Hermit) on Feb 18, 2005 at 07:11 UTC | |
by pernod (Chaplain) on Feb 18, 2005 at 09:26 UTC | |
by audreyt (Hermit) on Feb 18, 2005 at 11:02 UTC | |
by pernod (Chaplain) on Feb 18, 2005 at 13:21 UTC | |
by audreyt (Hermit) on Feb 18, 2005 at 14:23 UTC | |
Re: Hello Perl 6. Running pugs on Windows
by rg0now (Chaplain) on Feb 16, 2005 at 11:21 UTC | |
by stvn (Monsignor) on Feb 16, 2005 at 14:52 UTC | |
by pernod (Chaplain) on Feb 16, 2005 at 15:12 UTC | |
by pernod (Chaplain) on Feb 16, 2005 at 11:43 UTC | |
by rg0now (Chaplain) on Feb 16, 2005 at 13:55 UTC | |
Re: Hello Perl 6. Running pugs on Windows
by cog (Parson) on Feb 16, 2005 at 09:51 UTC | |
Re: Hello Perl 6. Running pugs on Windows
by gaal (Parson) on Feb 18, 2005 at 09:40 UTC | |
Pugs now works - but how?
by rg0now (Chaplain) on Feb 18, 2005 at 22:12 UTC | |
by pernod (Chaplain) on Feb 18, 2005 at 22:56 UTC | |
by awwaiid (Friar) on Feb 18, 2005 at 23:20 UTC | |
by rg0now (Chaplain) on Feb 19, 2005 at 23:41 UTC |