root/v6/v6-KindaPerl6/docs/FAQ.pod

Revision 19153, 14.4 kB (checked in by dlo, 7 months ago)

[kp6] fixed infix space problem

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1 =head1 NAME
2
3 KindaPerl6 - Frequent Asked Questions.
4
5 =head1 DEVELOPMENT
6
7 Development of KindaPerl6 is coordinated almost via the #perl6 IRC channel on
8 irc.freenode.net. If you want to contribute join the channel and ask for a
9 commit bit (see L<http://dev.pugscode.org/wiki/>).
10
11 =head2 Useful links
12
13 These are perl6 links, that I believe would be useful for new people to the
14 KindaPerl6 project.
15
16 L<http://dev.pugscode.org/browser> Trac interface for Perl6 code
17
18 L<http://svn.pugscode.org/pugs/> SVN Repository
19
20 L<http://feather.perl6.nl/syn/> Official Perl6 Documentation
21
22 L<http://sial.org/pbot/perl6> Paste Bot for #perl6
23
24 L<http://irclog.perlgeek.de/perl6/today> IRC Chat history for #perl6
25
26 L<http://www.cse.unsw.edu.au/~dons/lambdabot/COMMANDS> Commands for lambdabot in #perl6
27
28 L<http://dev.pugscode.org/timeline> Recent Commits
29
30 L<http://dev.pugscode.org/browser/v6/v6-KindaPerl6/TODO> KP6 TODO
31
32 =head2 mp6/kp6 FAQ
33
34 =head2 Overview - What is mp6/kp6/v6?
35
36 v6 is a perl6-on-perl6 project:  L<http://dev.pugscode.org/browser/v6>
37
38 This is not the perl5 v6-alpha, see perl5/Pugs-Compiler-Perl6 for that.
39
40 The current plan is to bootstrap full-p6 using kp6.
41
42 There are 4 subprojects under v6/:
43
44 =over
45
46 =item MiniPerl6 aka mp6
47
48 v6-MiniPerl6 (mp6) is a subset of Perl 6 used to bootstrap the full Perl 6.
49 v6-MiniPerl6 is bootstrapped with perl5.
50
51 =item KindaPerl6 aka kp6
52
53 v6-KindaPerl6 is a reimplementation of mp6 with a very flexible compiler
54 workflow.  kp6 uses plugins in order to implement perl6 semantics over several
55 backends.  kp6 is currently being bootstrapped - kp6 is compiled with the mp6
56 compiler.
57
58 =item Yet Another Perl6 aka yap6
59
60 A pure C implementation of KindaPerl6 runtime
61
62 =item Onion
63
64 Next iteration of the kp6 project
65 I<This project was a shortlived experiment.Work on the bootstap is now going inside kp6.The name is reserved for perl6 on parrot>
66
67 =item v6.pm
68
69 v6.pm is a plain translation of the perl5 v6.pm compiler, such that the modules
70 could be interchangeable. This project is currently abandoned.
71 I<This project has been removed.>
72
73 =item v6-Compiler
74
75 v6-Compiler (full-p6) is meant as a more advanced compiler, but the process is
76 more  difficult to bootstrap because v6-Compiler needs a more complete Perl 6
77 compiler.
78 I<This project has been removed.>
79
80 =item pugs - the Haskell implementation
81
82 PUGS is the root: L<http://dev.pugscode.org/browser> .  There are several
83 different perl6 implementations in progress.  PUGS is one of them.
84
85 =back
86
87 =head2 How can I help?
88
89 =head3 Prerequisite reading.
90
91 Perl6 is implementing several features I have not heard of before.  Before
92 you read the perl6 documentation, these documents are good to read.
93
94 - Prototyped based programming: L<http://en.wikipedia.org/wiki/Prototype-based_programming>
95
96 The perl5 code that implements Prototyped classes: L<http://search.cpan.org/dist/Class-Prototyped/lib/Class/Prototyped.pm>
97
98 - Objects (Autoboxing is interesting): L<http://en.wikipedia.org/wiki/Autoboxing#Autoboxing>
99
100 =head3 What do you need?
101
102  - Perl5 (Perl 5.10.RC2 and Perl 5.8.8 worked with the kp6 test cases.)
103  - Coro.pm : L<http://search.cpan.org/~mlehmann/Coro-4.13/Coro.pm>
104    Required for t/kp6/internals/02-gather.t
105  - Subversion client.
106  - Commit bit: Ask on #perl6 irc.freenode.net.
107
108 =head3 Customs and Traditions.
109
110 - (new comers) When you get your commit bit, Update the AUTHORS file to make sure everything (SVN) is ok.
111
112 - Commit code in doubt, revert if wrong.<br>
113
114 L<http://irclog.perlgeek.de/perl6/2007-10-31#i_135203>
115
116 - Please prefix your kp6 svn commits with [kp6]
117
118 L<http://irclog.perlgeek.de/perl6/2007-11-01#i_136077>
119
120 Example:
121
122  [kp6] I have refactored subroutine XXX for clarity and updated the documentation.
123
124 =head3 Seeing an intermediate step.
125
126 Sometimes you want to see how kp6 "saw" the code.  This is seen by running the
127 code though AST backend.
128
129  perl script/kp6 -Cast -e ' "a" eq "b" '
130
131 =head3 Cannot see the forest for the trees. / Boot strapping
132
133 One of the problems I had when I started working on kp6 was I could not see
134 how everything worked together.
135
136 mp6.pl (miniperl6) is used to compile/translate the AST/Grammar/Visitor perl6
137 libraires/code into perl5 code that can be used by kp6 to parse new perl6 code.
138
139 AST/Grammar/Visitor code is responsible for converting perl6 code into perl5
140 code or some other backend (Parrot/Lisp/Perl5).
141
142 Once the kp6 is sufficently working, you can use kp6 to compile the AST/Grammer/Visitor
143 perl6 code to produce NEWER, better, libraries.  The new libraries replace the
144 existing libraries/code produced by mp6.  Ergo, miniperl6 is no longer needed;
145 kp6 has just bootstrapped itself.
146
147 The mp6.pl files are:
148
149  src/KindaPerl6/Ast.pm
150                 Grammar.pm
151                 Traverse.pm
152
153  src/KindaPerl6/Grammer/*
154
155  src/KindaPerl6/Visitor/*
156
157 kp6 provides a Runtime enviroment for perl6 code with src/KindaPerl6/Runtime/*
158 so that we can execute perl6 code that has been translated to perl5.
159
160 =head2 What subset of Perl 6 is covered by mp6?
161
162   (from miniperl6-spec.pod)
163
164 =over
165
166 =item
167
168 A program is organized in compilation units. All statements must be inside a
169 'class' declaration: class X { ... }
170
171 =item
172
173 All statements finish with semicolon.
174
175 =item
176
177 Only allow one feed of positional arguments.
178
179 =item
180
181 In Signature, disallow "is slurpy", "is optional", "is named" (*@bad) ($bad?)
182 (:$bad)
183
184 =item
185
186 But we do allow Hash and Array and Tree unpacking:
187
188  sub foo ([$a, $b, $c], {:$x, :$y}, ::Tree $top (:$left, :$right)) { ... }
189
190  foo([1, 2, 3], { x => 1, y => 2 }, ::Tree( left => 1, right => 2 ));
191
192  # This compiles to:
193  sub foo {
194      my perl6::Tree $top;
195      my ($a, $b, $c, $top, $x, $y, $left, $right);
196      ($a, $b, $c)  = @_[0];
197      ($x, $y)      = @_[1]{'x', 'y'};
198      $top          = @_[2];
199      ($left, $right) = ($top.left, $top.right);
200      ...
201  }
202
203  foo([1, 2, 3], { x => 1, y => 2 });
204
205 =item
206
207 As a consequence, object constructor calls must be written in coercion form:
208
209  ::Foo( x => 1, y => 2 );   # NOT Foo.new
210
211 =item
212
213 Only allow item context.
214
215 =item
216
217 No laziness; all List are Sequences.
218
219 =item
220
221 No subtyping (inheritance) or role mixings.
222
223 =item
224
225 No first-class Capture and Signature objects, which means no \$x nor :(foo)
226
227 =item
228
229 No assignment, only bindings, but do not panic:
230
231  $x := $x + 1;   # name = IntOp(named(Int))
232  # $x = $x + 1
233
234 The reason is we have to eliminate one of them to avoid dealing with:
235
236  $x := $y;
237  $x = 123;
238
239 Because assignment always involve box(unbox()), so emitting the binding to Perl
240 5 is much more straightforward as $x is always just a Int in ($x := $x + 1),
241 never SomePossiblyTiedScalarContainerType that needs to have special FETCH magic
242 associated with $x.
243
244 Also it (WHAT IS "IT"?) is inevitable with eliminating list context, because:
245  ($x, $y, $z) := (1, 2); # compile-time error.
246  ($x, $y, $z) = (1, 2);  # list-context-undef-fill that we do not want to deal with.
247
248 Because infix:<=> almost always imply slurpiness with LHS is not a simple
249 scalar, eliminating it is consistent with eliminating list context.
250
251 =item
252
253 Annotations are preserved in Perl 5 emitted code using simple Typed vars:
254
255  # MiniPerl6
256  my Int $x;
257  my perl5:CGI $x;
258
259  # Compiled Perl 5
260  my perl6::Int $x;
261  my CGI $x;
262
263 The compiler adds no extra assertions, there for using types will not degrade
264 performance in MiniPerl6 land.
265
266 =item
267
268 No coroutines. No continuations
269
270 =item
271
272 Categories and precedence levels
273
274 =item
275
276 ; no BEGIN blocks!
277
278 =back
279
280 =head2 Can mp6 be run in perl5?
281
282 Yes.  Perl5 is currently the only fully working backend.
283
284 =head2 Can mp6 be run in pugs?
285
286 We are not aware of anyone who has tried.  Please let us know, if someone has
287 tried.
288
289 =head2 Can mp6 be run in parrot?
290
291 There is an implementation of a parrot emitter, but the emitter cannot run
292 full-mp6 yet.
293
294 The implementation of the PAST emitter was also under way.
295
296 =head2 Can mp6 be run in ruby/javascript/c#/c/d ?
297
298 There is some work done for a D implementation.
299
300 Ruby and Javascript can probably reuse some work that was done for redsix and pil2js.
301
302 =head2 Running mp6
303
304 There are control scripts for compiling mp6 to several backends:
305
306 Perl 5:
307
308  perl mp6-perl5-boot.pl < source.pl > dest.pl
309
310 Parrot:
311
312  perl mp6-parrot.pl < source.pl > dest.pir
313
314 Parrot-PAST:
315
316  perl mp6-past.pl < source.pl > dest.past
317
318 =over
319
320 =item Bootstrapping mp6-perl5:
321
322 This script rebuilds the lib5 directory. It creates a directory named lib5-new:
323
324   cd pugs/v6/v6-MiniPerl6
325   perl util/build-perl5.sh
326   mv lib5 lib5-old
327   mv lib5-new lib5
328
329 =item What subset of Perl 6 is covered by kp6?
330
331 kp6 reuses the mp6 grammar.  The main differences are not visible - kp6 adds an
332 extra (Abstract Syntax Tree) AST processing step.
333 kp6 adds:
334
335  - lexical subs
336  - metamodel interface
337  - lexical classes (planned, not implemented)
338  - begin blocks
339  - containers
340
341 =item Running kp6
342
343 kp6 works by creating a parse tree, which is then submitted to a list of AST
344 processors called "Visitors" (namespace C<KindaPerl6::Visitor::*>).  Which is
345 then handed off to the KindaPerl6/Visitor/Emit/Perl5.pm to be translated into
346 perl5.
347
348 script/kp6 is one of the possible compiler 'workflows' that can be built with
349 kp6.  You can specify other workflows such as lisp by specifying a different
350 backend with -B, perldoc script/kp6 for more info.
351
352 perl script/kp6 -o dest.pm source.pm
353
354  perl script/kp6 -e 'say 42;'
355  ---
356  42
357
358 To execute a Perl 6 script directly type
359
360  perl script/kp6 source.p6
361
362 =item Compiling kp6
363
364 As of this writing, kp6 is not bootstrapped (in progress though).
365
366 The kp6 source files can be compiled with mp6 (whith the exception of the
367 KindaPerl6::Runtime::Perl6::* files, which are compiled wih kp6). There
368 is a 'mp6.pl' script in kp6 directory:
369
370 Please use the make file to compile these.
371
372  make forcerecompile
373  make
374  make test
375
376 These will force compilation of various files.
377
378 Example:
379
380  perl mp6.pl < lib/KindaPerl6/Visitor/EmitPerl5.pm > lib5/KindaPerl6/Visitor/EmitPerl5.pm
381  -or-
382  perl mp6.pl -o lib5/KindaPerl6/Visitor/EmitPerl5.pm lib/KindaPerl6/Visitor/EmitPerl5.pm
383
384 =back
385
386 =head2 How much of the test suite passes?
387
388 A few tests pass.
389
390 In mp6, you can pass t/01-sanity/01-tap.t by preprocess by removing of
391 "use v6-alpha;" and wrapping the input in "class Main {...}". See pugs/project_planning/TALK.
392 Some tests pass for kp6. See end of file in v6/v6-KindaPerl6/scripts/run_test.pl
393
394 =head2 How much of the test suite will eventually pass?
395
396 Passing tests depends on improving the grammar and the runtime.
397 Instead, kp6 focus is now on bootstraping.
398
399
400 =head2 Why does parsing take so much time?
401
402 The parser is recursive-descent.
403
404  "Ziggy6" pasted "Total Elapsed Time = 20.53264"
405  Total Elapsed Time = 20.53264 Seconds
406  User+System Time = 19.45264 Seconds
407  Exclusive Times
408  %Time ExclSec CumulS #Calls sec/call Csec/c  Name
409  42.7   8.307  8.446 253776   0.0000 0.0000  MiniPerl6::Perl5::Match::new
410  30.4   5.918  5.876 150690   0.0000 0.0000  MiniPerl6::Perl5::Match::to
411  15.0   2.919 11.171  36356   0.0001 0.0003  MiniPerl6::Grammar::ws
412  8.58   1.669  1.688 253776   0.0000 0.0000  MiniPerl6::Perl5::Match::DESTROY
413  5.58   1.085  1.037 259216   0.0000 0.0000  MiniPerl6::Perl5::Match::__ANON__
414  5.36   1.042 12.035  20975   0.0000 0.0006  MiniPerl6::Grammar::opt_ws
415  4.67   0.909  2.824  36400   0.0000 0.0001  MiniPerl6::Grammar::newline
416  ...
417
418 The code generated by the parser makes several method calls on each
419 character - this can be optimized with inlining (not planned for mp6).
420 A MiniPerl6::Perl5::Match is created for every character.
421
422 =head2 Why isn't kp6 self-hosting?
423
424 kp6 will be self-hosting. The process depends on a fast enough parse engine and porting
425 thing using the mp6 calling conventions.
426
427 =head2  What is the plan for kp6?
428
429 =over
430
431 =item Provide a minimal bootstrapped language implementation for bootstrapping p6-on-p6.
432
433 Extra features over mp6 - allow the implementation of BEGIN blocks, flexible grammar.
434
435 =item Implement a flexible/pluggable compiler engine.
436
437 This is currently done with a Visitor pattern for AST transforms.
438
439 =item Lexical subs
440
441 Allows operator redefinition:
442
443 my multi infix:<+> { ... }
444
445 But note that 'multi' is not part of the kp6 spec.
446
447 =item Lexical classes / first-class classes.
448
449 Better support for grammar mutability:
450
451  $?GRAMMAR   Which grammar am I in? (from S02)
452  @?GRAMMAR   Which nested grammars am I in?
453
454 Update: Lexical classes will not be implemented.
455
456 =item Metamodel interface
457
458 Allow pluggable object models.
459
460 =item BEGIN blocks
461
462 BEGIN blocks are needed to seperate compile-time from run-time.
463
464 =item Containers
465
466 This is needed to implement assignment - MP6 only supported binding.
467
468 =back
469
470 =head2 Is kp6 needed for bootstrapping perl 6 on perl 6?
471
472 No. perl 6 on perl 6 can also be bootstrapped with:
473
474  - Parrot
475  - Pugs
476  - v6.pm
477  - Plain mp6
478  - Redsix L<http://dev.pugscode.org/browser/misc/pX/Common/redsix>
479
480 =head2 How to use kp6 to compile everything.
481
482 TODO: make KP6-BOOT
483
484 =head2 How to: make / compile / test  -  kp6
485
486 =over
487
488 =item Download KindaPerl6.
489
490  svn co http://svn.pugscode.org/pugs/
491
492 =item To compile KP6.
493
494  perl Makefile.PL
495  make -j 3 test
496
497 I<-j 3 means do 3 jobs at once, great for systems with SMP>
498
499 =item To re-compile KP6.
500
501  make clean
502  perl Makefile.PL
503  make -j 3 test
504
505 =item Force re-compilation of everything.
506
507  make forcerecompile
508  setenv PERL5LIB "./inc/v6-MiniPerl6-lib5" (XXX can this step be removed?)
509  make
510
511 I<WARNING: Do NOT use -j when forcing a recompile!, this will cause the Makefile
512 to crash.  The make process will attempt to use code that has not yet been
513 compiled.>
514
515 =item To execute a script.
516
517  perl scripts/kp6 [perl6 file]
518
519
520 =item To compile a perl6 script and view resulting source:
521
522  perl scripts/kp6 -o [outputfile.pl] [source perl6 file]
523
524 =item To debug perl6 in perl5 code scripts.
525
526  setenv PERL5LIB compiled/perl5-kp6-mp6/lib
527  perl -d (some script)
528  DB> $DB::deep = 500;
529
530 I<Do to the recurisve nature of the code, you're likely to hit 100 pertty fast.>
531
532 =back
533
534 =head2 Miscellaneous Notes
535
536 L<http://irclog.perlgeek.de/perl6/2007-01-22#i_-60765>
537
538 fglock: hmm - maybe for mp6; need to find a way to do eval() to
539
540 L<http://cataclysm.cx/2006/08/19/closures-in-c/>
541
542  Closures in C
543  By: eaten by a grue
544
545 =head2 See Also
546
547 A Two-Dimensional Separation of Concerns for Compiler Construction
548
549 L<http://www.cis.uab.edu/gray/Pubs/sac-2005-carl.pdf>
550
551 - Compares the visitor pattern (used by kp6) with other approaches
552
553 =head1 AUTHORS
554
555 The Pugs Team E<lt>perl6-compiler@perl.orgE<gt>.
556
557 =head1 SEE ALSO
558
559 The Perl 6 homepage at L<http://dev.perl.org/perl6>.
560
561 The Pugs homepage at L<http://pugscode.org/>.
562
563 =head1 COPYRIGHT
564
565 Copyright 2007 by Flavio Soibelmann Glock and others.
566
567 This program is free software; you can redistribute it and/or modify it
568 under the same terms as Perl itself.
569
570 See L<http://www.perl.com/perl/misc/Artistic.html>
571
572 =cut
Note: See TracBrowser for help on using the browser.