Re: Compiling Perl to Bytecode (Was: Fruit basket program in Boo)

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 22 Oct 2007 21:45:12 +0300

Yes I know that module, but... have you tried it?

I've tried it and for some more complex programs than a simple "Hello world" it doesn't work.

It works as good as the program perlcc which is included in perl and which should be able to compile a perl program into an executable.
(unfortunately)

I hope perl 6 will be ready sooner than 10 years from now on. :-)

Octavian

----- Original Message ----- From: "Veli-Pekka Tätilä" <vtatila@xxxxxxxxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Monday, October 22, 2007 8:37 PM
Subject: Re: Compiling Perl to Bytecode (Was: Fruit basket program in Boo)


Hi Octavian.
Actually, Perl can compile to byte code it is just that not many people
know it.

perldoc B::Bytecode

says:

   Compiles a Perl script into a bytecode format that could be loaded
later
   by the ByteLoader module and executed as a regular Perl script.

See the rest of the manual page for an example and some switches.

Similarly

perldoc -f require hints:

           <snip> Before "require" looks
           for a ".pm" extension, it will first look for a filename
with a
           ".pmc" extension. A file with this extension is assumed to
be
           Perl bytecode generated by B::Bytecode. If this file is
found,
           and its modification time is newer than a coinciding ".pm"
           non-compiled file, it will be loaded in place of that
           non-compiled file ending in a ".pm" extension.

This applies to use as well:

perldoc -f use

           It is exactly equivalent to

               BEGIN { require Module; import Module LIST; }

           except that Module *must* be a bareword.

I'm sure you'll be able to find some examples on the inet, too. The
bytecode support is still a bit experimental and there are certain
special cases and switches you should read about in the B::Bytecode man
page. Note that the

perl -MO

syntax means loads a special module called O which loads the Perl
compiler backends under the B::namespace. YOu can even disassemble Perl
code annd often the B::Deparse module is a great help in interpreting
how Perl actually executed your expression. See its man page, too.

--
With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila

Octavian Rasnita wrote:
<snip>>
If perl would be able to byte-compile the code and if there would be a
friendly GUI library which is accessible and supports UTF-8, (and not a bad programming interface library like WX), I would be using only perl, because it has very many advantages in the other fields, and it is very productive.
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: