root/v6/v6-KindaPerl6/docs/kindaperl6-spec.pod

Revision 18045, 5.6 kB (checked in by fglock, 15 months ago)

[kp6] set svk eol, mime-type properties

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1KindaPer6 specification
2
3- in short: lexical subs and classes; metamodel interface; begin blocks; containers
4  - see individual files:
5    begin-block.pod
6    lexical-class.pod
7    lexical-subs.pod
8
9- compilable with MP6, only until KP6 bootstraps
10  - MP6 spec is now frozen
11
12- pluggable, maybe hot pluggable:
13  grammar, object system, and the workflow itself
14
15  The initial default grammar engine could be reused from MP6 
16  Parrot backend could use TGE/PGE
17  Perl5 backend could use PCR, MO, Moose
18
19# Milestones
20
21- finish kp6-spec
22
23    Such that we know when it's finished
24
25- lexical subs
26
27    Allows operator redefinition:
28   
29    my multi infix:<+> { ... }
30
31    But note that 'multi' is not part of the kp6 spec
32
33- lexical classes / first-class classes
34
35    Better support for grammar mutability
36
37    $?GRAMMAR   Which grammar am I in? (from S02)
38    @?GRAMMAR   Which nested grammars am I in?
39       
40- metamodel interface
41
42    Allow pluggable object models
43
44- begin blocks
45
46    This is needed to support separate compilation - that is, separate compile-time from run-time
47
48- containers
49
50    This is needed to implement assignment - MP6 only supported binding.
51
52# Compiler
53
54- Pads and OO are implemented as external module calls
55- Containers?
56
57    http://www.mail-archive.com/perl6-language@perl.org/msg25373.html
58    ---
59    class Pad {
60     has %!myvars;
61     has Pad $.outer;
62   
63     method lookup(String $var) {
64       return %!myvars{$var} if exists %!myvars{$var};
65       return $.outer.lookup($var);
66     }
67     method set(String $var, $val) {
68       %!myvars{$var} = $val if exists %!myvars{$val};
69       return $.outer.lookup($var, $val);
70     }
71     ...
72    }
73    ---
74
75    from MiniPerl6-MO:
76    ---       
77    - "class" is a macro. It expands to a "module", with calls to MO.
78      The "module" AST is like:
79   
80      # A module is a "class" without the methods and attributes.
81      class Module {
82        has $.name          is Str;                     # Module Name;
83        has $.body          is Lit::Code;               # body of code
84      }
85   
86    - Macros are implemented in the grammar.
87    - It might be better to implement syntax for macros first, and then
88      implement "token" and "class" using real macros
89   
90    - Method calls can either be implemented with mo subroutine calls, or native method calls.
91      It depends on the emitter
92    ---
93   
94    from MO/t/mi.t
95    ---
96    my $base = MO::Compile::Class::MI->new();
97   
98    my $point = MO::Compile::Class::MI->new(
99        superclasses => [ $base ],
100        instance_methods => [
101                MO::Compile::Method::Simple->new(
102                        name       => "distance",
103                        definition => sub {
104                                my ( $self, $other_point ) = @_;
105                                die "stub";
106                        }
107                ),
108        ],
109        attributes => [
110                MO::Compile::Attribute::Simple->new(
111                        name => "x",
112                ),
113                MO::Compile::Attribute::Simple->new(
114                        name => "y",
115                ),
116        ],
117    );
118    ---
119
120# Differences from MiniPerl6
121
122- assignment with '='
123
124- inheritance
125
126- trait blocks
127
128
129# Wish list
130
131- macros
132
133
134# Extensibility
135
136KP6 extensibility should make it is possible to implement Perl6 using it.
137Some test cases could be (as long as the backend supports it):
138
139- 'my' subroutines
140  - p5 backend can use Sub::Lexical instead (but it is a source filter)
141- 'my' classes
142    - lexical grammar changes, such as
143      my multi infix:<+> ...
144      - the p6-parser is executed in the lexical context under compilation
145    ---
146    <TimToady> when you're building the candidate list for a particular multi dispatch, it goes outward in the scopes and finds any candidates whose long name is not hidden by an inner scope
147    <TimToady> finally it adds in all the global multies
148    <fglock> I think what I mean is, the whole grammar is inside the scope
149    <TimToady> logically, yes
150    <TimToady> reverts to previous grammar at }
151    <fglock> rather than being a simple external module
152    <TimToady> yes, you generally have to construct an anonymous grammar
153    <TimToady> and that anon grammar may well be based on the OUTER:: anonymous grammar
154    <TimToady> the current grammar is also passed to eval, i think.
155    <TimToady> but not to require
156    <TimToady> so in the case of eval you need to remember the current grammar in $?GRAMMAR till run time
157    <TimToady> that anonymous grammar is where you probably want to store the modified infix etc. tables
158    <TimToady> rather than just temporizing, or in addition to temporizing
159    <TimToady> basically a GC problem; if anything refers to $?GRAMMAR you keep it around.
160    ---
161   
162- 'coro'
163
164- junctions
165
166
167# Desugarings to MP6
168
169- metamodel calls for OO
170
171- cps - continuation-passing style
172
173- explicit pads as program data
174  - not really needed - see note below
175- special blocks: BEGIN, LAST, ...
176  note - p5 can access pad structures using closures:
177  --- Perl 6 source
178    module Main;
179    my $y; 
180    my $z;
181    BEGIN {
182        my $x; 
183        $y = { $x };   
184        $z = { $x }
185     }
186  --- Perl 5 run-time
187    INIT {
188        Main::_begin_001_();
189    }
190    package Main;
191    my $y; 
192    my $z;
193    sub _begin_001_ {
194        my $x; 
195        $y = sub { $x };   
196        $z = sub { $x }
197    }
198  ---
199
200- parameter binding
201  - already done by mp6, but it's incomplete
202
203
204# AST transformation engine
205
206Desugaring is processed by the ast-transformation engine
207
208    compiler workflow
209        ->
210    @visitors ---> visitor composer ---> AST traverser
211
212
213# See also
214
215- misc/pX/Common/lrep/Notes-Pugs.pm
216  some notes about compiler plugins
217
218- misc/pX/Aside/design_space_sketch_Feb_11
219  a previous plan
220 
221- Compiling Embedded Languages
222  conal.net/papers/saig00/compile-dsel.pdf
Note: See TracBrowser for help on using the browser.