There are no tags for this page.
Perl 6

Integrating SMOP and P5

This page describes the sketches on how to implement a p5<->SMOP integration that would allow to fully implement Perl 6 cooperatively with p5. The branch is being hosted in github http://github.com/pmurias/perl

Important Considerations

  • This is going to be a modified p5 interpreter, so it's going to have a different @INC and every module will need to be recompiled to this modified interpreter, just as needed for a new major p5 version.
  • The main loop will be the p5 loop, the basic idea is making the p5 interpreter to support the SMOP Interpreter API meaning that you're going to use the p5 interpreter as the SMOP interpreter object.
  • This all is possible because SMOP assumes that every object is opaque and that the only one allowed to access the object's structure is its responder interface, which happens to be the first member of the SMOP__Object struct.

Predicted Steps

  1. Add polymorphic representation support to p5. This will mean adding the SMOP__ResponderInterface to every value in p5, among them SV and the interpreter itself.
  2. Dynamically create ResponderInterfaces for each of the p5 values (the interpreter itself, SV and other things) and use them when creating this values. This will allow the interpreter to realize which values belong to it or not. This ResponderInterfaces will be set in the interpreter allowing simple pointer comparison.
  3. Add checks in every p5 macro to see if the referred value's RI is one of this interpreter's RI, using SMOP_DISPATCH otherwise.
  4. Implement $interpreter.continuation(), that returns the current continuation. This will, in the case of running p5 code, construct a Coro::State-like object containing the current continuation.
  5. Implement $interpreter.goto($continuation), that will set that continuation as the current continuation. If that continuation is a p5-continuation it does something like Coro::State load_perl, but if it's something else, it will set a static OP_PolymorphicEval and set the continuation object in the interpreter. This OP_PolymorhicEval will use the SMOP Interpreter Implementation API on the given $continuation.

Side-effect benefits

  • Polymorphic representation is probably the coolest feature of Perl 6, implementing that, even without Perl 6, is already a very interesting feature, you wouldn't need to make a SvRV(newSViv(*object)) to embed foreign objects.
  • Polymorphic eval is the coolest feature of SMOP, even without Perl 6, that would allow cooperating with other interpreters easily, for instance, one could cooperatively run the stackless python alongside p5.


Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.