|
Perl 6
SMOP s1p Language: Revision 2
Considering SMOP doesn't use the C stack for regular operation, we have an important side effect that not even the built-in types can recurse in the C stack. They must recurse only using the SMOP interpreter, and only do C recursion when really needed. This way, it sounds a little awkward to write C code that doesn't run like normal C code. It would tend to be worse than XS. That's why we need a Stage 1 language. This language would result in the equivalent C code to declare the type. This code, by one side, is just plain Perl 6, because the object support is the same as Perl 6, but, as a Stage 1 there are some limitations of what code can be generated, remembering that this Stage 1 code must be subject to translation into C code. Basically, this language will be used to build a interpreter operations. And to do that, it doesn't need:
This basically means that all lexical information will be translated to anonymous stack referencing, as block names, and they will only be accessible from the current file. On the other hand, the language will be used, at the same time, to describe the built-in types and implement them in high level. In order to allow this description, while recognizing the limitations, so here we get to a more precise description. The stage 1 language will describe Classes that happens to be built-in classes, so the basic syntax will be the same as of a regular Perl 6 class, the methods will be understood as the class methods, subroutines are not allowed. Small exercise
class Foo {
has $.a;
has $!b;
method foo {
return self.bar
}
method bar {
return 1
}
}
Should be translated into #include <smop.h> #include <smop_lowlevel.h> #include <smop_oo.h> |