All-

This is to announce the push to our git repository of
a basic infrastructure for implementing the STRING arg
option to the PDL::new constructor (a.k.a. pdl).

I did not have time to get going with the parsing but
here is the new POD for the PDL::new constructor and a
quick example in perldl with the new capability:

$ perl -Mblib perldl
perlDL shell v1.352
  PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file
  'COPYING' in the PDL distribution. This is free software and you
  are welcome to redistribute it under certain conditions, see
  the same file for details.
ReadLines, NiceSlice, MultiLines  enabled
Reading /home/chm/.perldlrc...
Found docs database /c/chm/pdl/git/pdl/blib/lib/PDL/pdldoc.db
Type 'help' for online help
Type 'demo' for online demos
Loaded PDL v2.4.6_004 (supports bad values)
perldl> ?PDL::new
Module  PDL::Core
   PDL::new
     new piddle constructor method

      $x = PDL->new(SCALAR|ARRAY|ARRAY REF|STRING);

      $x = PDL->new(42);
      $y = new PDL [1..10];
      $z = new PDL "[1 2 3]";

     Constructs piddle from perl numbers and lists and strings with
     Matlab/Octave style constructor syntax.

      NOTE:

        STRING support is in development and should be
        considered experimental.  The hook for STRING
        support is provided by returning the value from
        PDL::Core::new_pdl_from_string() which is called
        with $new, $value, $this, and $type from the
        PDL::new constructor. For example, the following
        just takes a standard perl array ref syntax as
        a string:

        sub PDL::Core::new_pdl_from_string {
           my ($new,$value,$this,$type) = @_;
           my $val = eval $value;
           if (ref $val eq 'ARRAY') {
              return PDL::Core::pdl_avref($val,$this,$type);
           } else {
              barf "PDL::Core::new_pdl_from_string: error happened!\n";
           }
        }

     Docs from /c/chm/pdl/git/pdl/blib/lib/PDL/Core.pm


perldl> p pdl [1,2]
[1 2]
perldl> p pdl "[1,2]"
Warning: PDL::new: PDL::Core::new_pdl_from_string() not defined.
PDL: PDL::new cannot make piddle from string input '[1,2]'

Caught at file (eval 59), line 4, pkg main

perldl>        sub PDL::Core::new_pdl_from_string {
           }
        }
..{    >           my ($new,$value,$this,$type) = @_;
..{    >           my $val = eval $value;
..{    >           if (ref $val eq 'ARRAY') {
..{{   >              return PDL::Core::pdl_avref($val,$this,$type);
..{{   >           } else {
..{{   >              barf "PDL::Core::new_pdl_from_string: error happened!\n";
..{{   >           }
..{    >        }

perldl> p pdl "[1,2]"
[1 2]
perldl> q


Enjoy!
Chris

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to