pugscc --runparrot -e "'Hello, Parrot'.say"

1 view
Skip to first unread message

Autrijus Tang

unread,
Mar 22, 2005, 3:43:05 PM3/22/05
to perl6-c...@perl.org, perl6-i...@perl.org, perl6-l...@perl.org
(Cc'ing this post to p6i and p6l, as this is likely to concern folks
from all three mailing lists.)

As of Pugs revision 1024, this works:

% pugscc --runparrot -e "'Hello, Parrot'.say"

And yes, it does what you think it does. Pugs takes that Perl 6 source
code, produce an AST, triggers the Compiler backend, generates some
PIR code, saves it into "a.pir", and runs it with the parrot
executable in path. The compilation and execution speed are both very
fast, and will get faster with embedded Parrot and/or Ponie support in
the future.

This also works:

% pugscc --runhaskell -e "'Hello, Haskell'.say"

Instead of PIR, it generates raw Haskell code using Template Haskell,
compiles it with GHC, and runs the resulting executable. Template
Haskell is really good for prototyping and verifying a compiler; the
code it produces is also quite fast, within 20% of Perl 5 speed.

The old, undecorated form of "pugscc" also works. It can also be
written thus:

% pugscc --runpugs -e "'Hello, Pugs'.say"

The "--pugs" backend is the only one that guarantees to run
identically to the pugs interpreter. Unsurprisingly, it merely bundles
the evaluator with the Pugs AST, and makes an executable out from that.

On a somewhat more interesting note, if you can build Pugs with the
"PUGS_EMBED" environment variable set to "perl5" (that works on
FreeBSD for me, but apparntely not on many other platforms), then you
can do this:

% pugscc --runpugs -e "eval_perl5('print q[Hello, Perl5!]')"

The eval_perl5($str) form is but a temporary kluge; it will likely
become eval($str, :language<perl5>), or whatever form preferred by the
perl6 design folks. Suggestions welcome!

Aside from perl5, I plan to add embedding support for Haskell and C
via hs-plugins, and Parrot support via the embedding API. Of course,
once Ponie gets up to speed, I can replace Perl5 and Parrot embeds
with it, which will save a lot of value casting works.

Tomorrow I'll hack some more to get mandel.p6 working correctly on the
two new compiler backends. Thanks to Dan Sugalski's help on #parrot, I
have figured out the PIR-level supports to get this done. Parrot is
really much, much saner than I had hoped; it eeriely supports lots of
things needed by a Perl 6 implementation. I wonder why that is the
case. :-)

Thanks,
/Autrijus/

Aaron Sherman

unread,
Mar 22, 2005, 4:39:54 PM3/22/05
to Autrijus Tang, perl6-c...@perl.org
On Tue, 2005-03-22 at 15:43, Autrijus Tang wrote:
> (Cc'ing this post to p6i and p6l, as this is likely to concern folks
> from all three mailing lists.)

I'm restricting the distribution back down so that I'm not creating a
followup wave.

> As of Pugs revision 1024, this works:
>
> % pugscc --runparrot -e "'Hello, Parrot'.say"

How appropriate a revision number....

I must say that pugs continues to out-strip every expectation I've had.
Bravo!

> Tomorrow I'll hack some more to get mandel.p6 working correctly on the
> two new compiler backends. Thanks to Dan Sugalski's help on #parrot, I
> have figured out the PIR-level supports to get this done. Parrot is
> really much, much saner than I had hoped; it eeriely supports lots of
> things needed by a Perl 6 implementation. I wonder why that is the
> case. :-)

Oh, I think it's because Parrot was designed to be able to run Haskell
;-)

--
Aaron Sherman <a...@ajs.com>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Autrijus Tang

unread,
Mar 26, 2005, 12:49:43 PM3/26/05
to Leopold Toetsch, Autrijus Tang, perl6-i...@perl.org, perl6-c...@perl.org
On Sat, Mar 26, 2005 at 04:44:52PM +0100, Leopold Toetsch wrote:
> I had a look at the generated mandel.imc. Remarkable, how compact
> Parrot.hs is and what it already does.

Thanks. One of my remaining large TODOs before Pugs 6.2.0 is to
recode the evaluators in Template Haskell as Compile/Haskell.hs,
so all code is always compiled. The Template Haskell macros should
then be rewritten into something resembling your ast/ast.h, which
is an AST for generating syntactically and semantically correct PIRs,
without the need of hard coding any strings using PrettyPrinter.

I'd very much like to talk with you about Compile/Parrot/AST.hs
the next week -- IRC or SEE/MoonEdit/Skype if possible. I understand
you're on metered ISDN, and I'd gladly pay for your bandwidth fee. :)
But if mails are preferred for you, I can do that as well.

> 1) s__z = s__t # mandel.imc:149
>
> This aliases the two PMCs, it's specifically not an assignement.
> It's:
>
> set Px, Py # PREG(1) = PREG(2);
>
> both PMC registers point to the same thing then.

Aha! Thanks for the hint. I see that the form above should perhaps
be used for :=, not =. Fixed as r1200.

> 2) Parrot understands two forms of source line comments:
>
> a) C-like: #line "file" line

I'll use this for now; r1201.

> b) opcodes: setfile "file"
> setline line

What, no set-column? :-)

> 3) the "last" Continuations

Understood, will fix along with the AST refactoring.

> 4) substr shortut

Thanks, implemented as r1203.

> Please let us know, what else is needed in the near future.

I will definitely collect issues raised during my tomorrow's
YAPC::Taipei talk and get back to you.

Thanks,
/Autrijus/

Reply all
Reply to author
Forward
0 new messages