Sunday, June 21, 2009

Padre's Perl 6 support and Ecliptic

I recently felt the urge to improve Padre's Perl 6 support since I am supposedly the lazy co-maintainer of Padre::Plugin::Perl6 along with my fellow Perl Programmer Gabor Szabo. For programmers who do not know what Padre is, here is a quick summary:

"Padre is a Perl IDE that is simple to use for new Perl programmers but also supports large multi-lingual and multi-technology projects... Padre is written in Perl, runs on all three major desktop platforms (Windows, Mac OS X and Unix/GTK), and is distributed under the perl license."

So what's new?

Starting with version 0.44, Padre Perl 6 plugin has the following improved menu which allows the user to create Perl 6 code easily. At the moment, no wizards are implemented but that will be in a future release.



Generate code and export-to-HTML commands are now in the export menu. You can generate a Perl 6 executable or its Parrot Intermediate Representation (PIR) assembly code if you have rakudo installed on your machine.



You can now choose which syntax highlighting engine to use: my precious Syntax::Highlight::Perl6 which is based on Larry Wall's STD.pm. or Rakudo's Parrot Grammar Engine (PGE). Currently everything is implemented using the S:H:P6 STD highlighter since it parses all of the Perl 6 test suite and has more advanced error reporting. PGE syntax highlighter is experimental and is used only for coloring.




Perl 6 Quick Fixes & Ecliptic Support

I use Eclipse IDE a lot in my full-time Java job. I spend my remaining free time learning and writing Perl 5 and Perl 6 with Rakudo Perl 6 (which is a promising Perl 6 implementation). I finally decided in late May 2009 to port the most useful Eclipse features to Padre::Plugin::Ecliptic. One of these features is the Quick Fix (In Eclipse: CTRL-1). This helps the programmer in fixing some common errors and/or warnings very quickly. You'll be addicted to it, once you start using it :)

Sometimes you forget to declare a variable. In Perl 6, you always need to define variables (like a implicit Perl 5 "use strict;"). So when you get such an error, click on it and then press CTRL-~. You'll a get this small yellow box which gives you a couple of quick fixes which you can select by pressing ENTER. For example, if you have selected "Insert declaration for $line", Ecliptic will fix the error by inserting a 'my $line;' above the error.




There are a lot of currently implemented Perl 6 quick fixes such as:
  • Undeclared variables/routines.
  • Use of flow control keywords as subroutines like if(), unless(), ..etc
  • Use of . instead of ~ for string concatenation.
  • Use of -> instead of . for method call.
  • Use of C++ constructor syntax (in Perl 6 'new Foo' should be written as 'Foo.new').
I did not cover everything in this post but i will try to tell you more about it in the future. Any comments and/or suggestions are welcome. You can find me in #padre in irc.perl.org under the nickname azawawi.

1 comment:

Pradeep said...

Intersting post. Thanks

ppant