Inline.pm makes it easy to *extend* Perl with C. But what about
embedding Perl in C? As I thought about this problem I came up with an
entirely new programming language: CPR (C Perl Run). CPR is just like C
except that you have access to the entire internals of Perl using either
the Perl5 API, or the CPR API. Here is a 'Hello World' program in CPR:
-----------------------------------8<----------------------------------------
#!/usr/bin/cpr
int main(void) {
printf("Hello World, I'm running under Perl version %s\n",
CPR_eval("use Config; $Config{version}"));
return 0;
}
-----------------------------------8<----------------------------------------
Yup, you guessed it, run the code under the CPR interpreter (hashbang
style or not) and your C code gets compiled/run seamlessly just like
with Inline!
This is embedding turned inside out. You run 'cpr' which execs 'perl'
which uses 'Inline::CPR' which binds and invokes 'main'. So your whole C
program is really just a Perl extension. By rights, this gives you full
access to the Perl5 API. And if you wrap that with a nice clean 'CPR_'
set of macros, you kind of get a new language. Don't you? :-)
I wish to distribute this as Inline::CPR. Here is the DSLI info:
Inline::CPR adpO Simple way to embed Perl in C ala Inline INGY
--
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'