An alternative to xs
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

An alternative to xs

on

  • 559 views

XS has been the way to extend perl with C or C++ code for the past decade and a half. It has become a powerful but hard to tame beast....

XS has been the way to extend perl with C or C++ code for the past decade and a half. It has become a powerful but hard to tame beast.

In this lightning talk, I'm exploring an entirely new approach to extending perl, based on C++ metaprogramming instead of preprocessing. One that doesn't require a programmer familiar with both to learn yet another language.

Statistics

Views

Total Views
559
Views on SlideShare
559
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

An alternative to xs Presentation Transcript

  • 1. An alternative to XS‎ Leon Timmermans
  • 2. XS
      • Preprocessor
        • XS to C
        • C to Binary
      • Pros
        • Flexible
        • Mature
      • Cons
        • Yet another languages to learn
        • … that isn't even a language
        • Requires some understanding of the interpreter
        • Limited C++ support
  • 3. Templates
    • A compile-time feature of C++
    • Turns meta code into code
    • Turing complete, purely functional
  • 4. Example
    • #! /usr/bin/perl
    • use Modern::Perl;
    • use Extend qw/hello/;
    • hello('world');
  • 5. Example
    • package Extend;
    • use Modern::Perl
    • use Exporter 5.57 qw/import/;
    • our @EXPORT_OK = qw/hello/;
    • use Perlpp::Extend;
    • 1;
  • 6. Example
    • #include <perl++/perl++.h>
    • #include <perl++/extend.h>
    • using namespace perl;
    • static void hello(const char* world) {
    • printf(&quot;Hello %s &quot;, world);
    • }
    • static void exporter(Package& extend) {
    • extend.add(&quot;hello&quot;, hello);
    • }
    • EXPORTER(exporter);
  • 7. Example 2
    • #include <perl++/perl++.h>
    • #include <perl++/extend.h>
    • using namespace perl;
    • struct foo {
    • foo(const std::string&);
    • void bar(int barista);
    • std::string buz;
    • };
    • static void exporter(Class<foo>& extend) {
    • extend.add(init<std::string>());
    • extend.add(&quot;bar&quot;, &foo::bar);
    • extend.add(&quot;buz&quot;, &foo::buz);
    • }
    • EXPORTER(exporter);
  • 8. Thank you
    • Code at http://github.com/Leont/libperl--
      • CPAN will follow soon
    • Thanks for listening
    • Thanks EPO for sending me here
      • I'm the send-a-newbe