PDL::MyInlineMod - a simple PDL module containing inlined Pdlpp code


PDL documentation Contained in the PDL distribution.

Index


Code Index:

NAME

Top

PDL::MyInlineMod - a simple PDL module containing inlined Pdlpp code

SYNOPSIS

Top

  use PDL::MyInlineMod;

  $a = zeroes 10, 10;
  $twos = $a->plus2;  # a simple function

DESCRIPTION

Top

A simple example module that demonstrates the usage of inlined Pdlpp in a module that can be installed in the usual way.

FUNCTIONS

Top

myinc

a very simple pp function that increments its argument

  myinc(i();[o] o())

plus2

a very simple pp function that increments its argument by 2

  plus2(i();[o] o())

AUTHOR

Top

C. Soeller (C) 2002. All rights reserved. This code can be distributed under the same terms as PDL itself (see the file COPYING in the PDL distribution).

SEE ALSO

Top

perl(1).

Inline.

Inline::Pdlpp.


PDL documentation Contained in the PDL distribution.
# Below is the stub of documentation for your module. You better edit it!

package PDL::MyInlineMod;

# use strict;  # strict results in trouble with barewords when using Inline :(
# no strict 'vars';
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

require PDL::Exporter;
@ISA = qw(PDL::Exporter);
# functions you want to export into the caller's name space
@EXPORT_OK = qw(myinc plus2);
%EXPORT_TAGS = (Func=>[@EXPORT_OK]);

BEGIN { # in BEGIN to make sure we can use $VERSION in the
        # 'use Inline...' call below
$VERSION = '0.60'; # Inline requires this to be a *string* that matches
                   #          /^\d\.\d\d$/
                   # see Inline-FAQ for more info
}

use PDL::LiteF;

# quirk 1 follows
use Inline::MakePdlppInstallable;  # allow installation of this module

use Inline Pdlpp => DATA => # inlined PP code is below in DATA section
  NAME => PDL::MyInlineMod,    # required info for module installation
  VERSION => $VERSION;      # ditto, see Inline-FAQ for more info

# quirk 2 follows
Inline->init;               # you need this if you want to 'use' your module
                            # from within perldl or pdl2 and your Pdlpp code
                            # resides in the DATA section (as in this example)

# following required to make exported functions work!
# PDL::PP used to make these automatically but now we have
# to make them manually since *we* are writing the pm-file
*myinc = \&PDL::myinc;      # make alias in this module's name space
*plus2 = \&PDL::plus2;      # ditto

1;

__DATA__

__Pdlpp__

# some simple functions to test the whole thing

pp_def('myinc',
          Pars => 'i();[o] o()',
          Code => '$o() = $i() + 1;',
         );

pp_def('plus2',
          Pars => 'i();[o] o()',
          Code => '$o() = $i() + 2;',
         );