| 1 | |
|---|
| 2 | During my quest to figure out where the difficult programming of perl6 |
|---|
| 3 | implementation is done, I asked a few questions and received a few responses. |
|---|
| 4 | I have cleaned up the questions and responses and documented them here. The |
|---|
| 5 | question is "Where is the programming that makes programmer's work a lot |
|---|
| 6 | easier"; Method overloading, objects and so on. |
|---|
| 7 | |
|---|
| 8 | namespace resolution (lexical (my) / file (our) / global (local)) is partly done |
|---|
| 9 | in Runtime/Perl5/Pad.pm (footnote #11) |
|---|
| 10 | |
|---|
| 11 | I had to figure out what code does what? The AST (footnote #2) / Emit(ers) |
|---|
| 12 | (footnote #1) are too small to be doing the work, thus some other code had to be |
|---|
| 13 | doing the majority of the work. |
|---|
| 14 | |
|---|
| 15 | When thinking about the kindaperl6 compilation process; think of kindaperl6 as |
|---|
| 16 | being a translator rather than a compiler. kindaperl6's AST uses a visitor |
|---|
| 17 | pattern to convert [emit] perl6 code into perl5, parrot, or lisp. (footnote #1, |
|---|
| 18 | #7) |
|---|
| 19 | |
|---|
| 20 | One method to write the compiler would be to write a compiler in perl5 that |
|---|
| 21 | reads in the perl6 code and produces parrot PIR. While this is straight forward |
|---|
| 22 | process, writing a perl6 compiler in perl5 to compile perl6 provides a very |
|---|
| 23 | good self test. If the perl6 can compile itself, then the perl6 compiler |
|---|
| 24 | probably is correct. |
|---|
| 25 | |
|---|
| 26 | However, while looking at the perl6 compiler I realized that there is not enough |
|---|
| 27 | code in there to be a true compiler. There are whole blocks of code missing |
|---|
| 28 | that should be handling a lot of the difficult programming. Method overloading, |
|---|
| 29 | object handling and so on. |
|---|
| 30 | |
|---|
| 31 | The majority of the missing code is in the Parrot op code. (footnote #5) When |
|---|
| 32 | thinking about perl6/parrot, think of parrot as being a virtual machine that |
|---|
| 33 | that executes a subset of perl6 in an macro language. Kindaperl6 converts |
|---|
| 34 | perl6 code into Parrot PIR (future: convert perl6 code into a Parrot AST) |
|---|
| 35 | (footnote #4, #8). Parrot provides it's own object method handling code |
|---|
| 36 | (footnote #9) however that is not completed. However, Parrot Object code is |
|---|
| 37 | not done yet (footnote #10), and Object inheritance / virtual methods is |
|---|
| 38 | currently (Oct. 14 2007) done in the kp6 compiler/runtime (footnote #12). |
|---|
| 39 | |
|---|
| 40 | However, some perl6 code will be have to expanded into Parrot PIR such as the |
|---|
| 41 | regular expressions and grammars. Junctions where also noted as part of the |
|---|
| 42 | work that kindaperl6 would have to write out its own Parrot code to do |
|---|
| 43 | (footnote #6). |
|---|
| 44 | |
|---|
| 45 | Notable links: |
|---|
| 46 | |
|---|
| 47 | Parrot op code: |
|---|
| 48 | http://www.parrotcode.org/docs/ops/ |
|---|
| 49 | Description of parrot processing: |
|---|
| 50 | http://www.oreillynet.com/onlamp/blog/2006/03/inside_parrots_compiler_tools.html |
|---|
| 51 | |
|---|
| 52 | Footnotes: |
|---|
| 53 | |
|---|
| 54 | 0. Bulk of the conversation: |
|---|
| 55 | http://irclog.perlgeek.de/perl6/2007-10-24 |
|---|
| 56 | |
|---|
| 57 | 1. AST/Emit(ers): |
|---|
| 58 | http://svn.pugscode.org/pugs/v6/v6-KindaPerl6/src/KindaPerl6/Visitor/Emit |
|---|
| 59 | |
|---|
| 60 | 2. kindaperl6 AST |
|---|
| 61 | http://svn.pugscode.org/pugs/v6/v6-KindaPerl6/src/KindaPerl6/Ast.pm |
|---|
| 62 | Abstract Syntax Tree |
|---|
| 63 | http://en.wikipedia.org/wiki/Abstract_syntax_tree |
|---|
| 64 | 3. visitor pattern: |
|---|
| 65 | http://en.wikipedia.org/wiki/Visitor_pattern |
|---|
| 66 | |
|---|
| 67 | 4. http://irclog.perlgeek.de/perl6/2007-10-24#i_131304 |
|---|
| 68 | |
|---|
| 69 | 5. http://irclog.perlgeek.de/perl6/2007-10-24#i_131284 |
|---|
| 70 | |
|---|
| 71 | 6. http://irclog.perlgeek.de/perl6/2007-10-24#i_131293 |
|---|
| 72 | http://search.cpan.org/dist/Perl6-Junction/lib/Perl6/Junction.pm |
|---|
| 73 | |
|---|
| 74 | 7. http://irclog.perlgeek.de/perl6/2007-10-24#i_131293 |
|---|
| 75 | |
|---|
| 76 | 8. http://irclog.perlgeek.de/perl6/2007-10-24#i_131350 |
|---|
| 77 | |
|---|
| 78 | 9. http://www.parrotcode.org/docs/ops/object.html |
|---|
| 79 | |
|---|
| 80 | 10. http://irclog.perlgeek.de/perl6/2007-10-24#i_131401 |
|---|
| 81 | |
|---|
| 82 | 11. http://svn.pugscode.org/pugs/v6/v6-KindaPerl6/src/KindaPerl6/Runtime/Perl5/Pad.pm |
|---|
| 83 | http://svn.pugscode.org/pugs/v6/v6-KindaPerl6/src/KindaPerl6/Runtime/Perl6/Pad.pm |
|---|
| 84 | http://irclog.perlgeek.de/perl6/2007-10-24#i_131403 |
|---|
| 85 | |
|---|
| 86 | 12. http://irclog.perlgeek.de/perl6/2007-10-24#i_131400 |
|---|