Your SlideShare is downloading. ×
An alternative to xs
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

An alternative to xs

397
views

Published on

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.

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
397
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

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