Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pdl::philosophy(1) [redhat man page]

PHILOSOPHY(1)						User Contributed Perl Documentation					     PHILOSOPHY(1)

NAME
PDL::Philosophy -- what's behind PDL? DESCRIPTION
This is an attempt to summarize some of the common spirit between pdl developers in order to answer the question "Why PDL"? If you are a PDL developer and I haven't caught your favorite ideas about PDL, please let me know! An often-asked question is: Why not settle for some of the existing systems like Matlab or IDL or GnuPlot or whatever? Major ideas The first tenet of our philosophy is the "free software" idea: software being free has several advantages (less bugs because more people see the code, you can have the source and port it to your own working environment with you, ... and of course, that you don't need to pay anything). The second idea is a pet peeve of many: many languages like matlab are pretty well suited for their specific tasks but for a different application, you need to change to an entirely different tool and regear yourself mentally. Not to speak about doing an application that does two things at once... Because we use Perl, we have the power and ease of perl syntax, regular expressions, hash tables etc at our fingertips at all times. By extending an existing language, we start from a much healthier base than languages like matlab which have grown into existence from a very small functionality at first and expanded little by little, making things look badly planned. We stand by the Perl sayings: "simple things should be simple but complicated things should be possible" and "There is more than one way to do it" (TIMTOWTDI). The third idea is interoperability: we want to be able to use PDL to drive as many tools as possible, we can connect to OpenGL or Mesa for graphics or whatever. There isn't anything out there that's really satisfactory as a tool and can do everything we want easily. And be por- table. The fourth idea is related to PDL::PP and is Tuomas's personal favorite: code should only specify as little as possible redundant info. If you find yourself writing very similar-looking code much of the time, all that code could probably be generated by a simple perl script. The PDL C preprocessor takes this to an extreme. Minor goals and purposes We want speed. Optimally, it should ultimately (e.g. with the Perl compiler) be possible to compile PDL::PP subs to C and obtain the top vectorized speeds on supercomputers. Also, we want to be able to calculate things at near top speed from inside perl, by using dataflow to avoid memory allocation and deallocation (the overhead should ultimately be only a little over one indirect function call plus couple of ifs per function in the pipe). We want handy syntax. Want to do something and cannot do it easily? Tell us about it... We want lots of goodies. A good mathematical library etc. AUTHOR
Copyright(C) 1997 Tuomas J. Lukka (lukka@fas.harvard.edu). Redistribution in the same form is allowed but reprinting requires a permission from the author. perl v5.8.0 1999-12-09 PHILOSOPHY(1)

Check Out this Related Man Page

OBJECTS(1p)						User Contributed Perl Documentation					       OBJECTS(1p)

NAME
PDL::Objects -- Object-Orientation, what is it and how to exploit it DESCRIPTION
This still needs to be written properly. [Also, is there a good reason we don't recommend storing extra object data in the header hash?] Inheritance There are basically two reasons for subclassing piddles. The first is simply that you want to be able to use your own routines like $piddle->something() but don't want to mess up the PDL namespace (a worthy goal, indeed!). The other is that you wish to provide special handling of some functions or more information about the data the piddle contains. In the first case, you can do with package BAR; @ISA=qw/PDL/; sub foo {my($this) = @_; fiddle;} package main; $a = PDL::pdl(BAR,5); $a->foo(); However, because a PDL object is an opaque reference to a C struct, it is not possible to extend the PDL class by e.g. extra data via subclassing. To circumvent this problem PerlDL has built-in support to extent the PDL class via the has-a relation for blessed hashes. You can get the HAS-A behave like IS-A simply in that you assign the "PDL" object to the attribute named PDL and redefine the method initialize(). package FOO; @FOO::ISA = qw(PDL); sub initialize { my $class = shift; my $self = { creation_time => time(), # necessary extension :-) PDL => null, # used to store PDL object }; bless $self, $class; } All PDL constructors will call initialize() to make sure that your extensions are added by all PDL constructors automatically. The "PDL" attribute is used by perlDL to store the PDL object and all PDL methods use this attribute automatically if they are called with a blessed hash reference instead of a PDL object (a blessed scalar). Do remember that if you subclass a class that is subclassed from a piddle, you need to call SUPER::initialize. NEED STUFF ABOUT CODE REFs!! Examples You can find some simple examples of PDL subclassing in the PDL distribution test-case files. Look in "t/subclass2.t", "t/subclass3.t", etc. Output Auto-Creation and Subclassed Objects For PDL Functions where the output is created and returned, PDL will either call the subclassed object's "initialize" or "copy" method to create the output object. (See PDL::Indexing for a discussion on Output Auto-Creation.) This behavior is summarized as follows: o For Simple functions, defined as having a signature of func( a(), [o]b() ) PDL will call $a->copy to create the output object. In the spirit of the Perl philosophy of making Easy Things Easy, This behavior enables PDL-subclassed objects to be written without having to overload the many simple PDL functions in this category. The file t/subclass4.t in the PDL Distribution tests for this behavior. See that file for an example. o For other functions, PDL will call $class->initialize to create the output object. Where $class is the class name of the first argument supplied to the function. For these more complex cases, it is difficult to second-guess the subclassed object's designer to know if a "copy" or a "initialize" is appropriate. So for these cases, $class->initialize is called by default. If this is not appropriate for you, overload the function in your subclass and do whatever is appropriate is the overloaded function's code. AUTHOR
Copyright (C) Karl Glazebrook (kgb@aaoepp.aao.gov.au), Tuomas J. Lukka, (lukka@husc.harvard.edu) and Christian Soeller (c.soeller@auckland.ac.nz) 2000. Commercial reproduction of this documentation in a different format is forbidden. perl v5.14.2 2012-01-02 OBJECTS(1p)
Man Page