ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Use of ChartDirector in Raku (formerly perl6)
Posted by wingfold on Apr-26-2022 23:11
Hi,

I'm intending (hoping) to rewrite a lot of perl5/chartdir code into raku.   I'm using the Inline::Perl5 module (https://github.com/niner/Inline-Perl5) which enables use of perl5 modules in raku (including .so/libraries) (and which works with every other module I've tried).   I'm hitting problems reproducing the "first project" example on the chartdir site (https://www.advsofteng.com/doc/cdperldoc/firstproject.htm).  All seems fine (i.e., data-dumping $c after line 8 shows a large/reasonable looking structure) until line 9 where I receive "No such method 'setPlotArea' for invocant of type 'XYChart'".  Line 10 does appear to work (no complaints) - remaining 3 lines don't (same type of error as for line 8).

I realize this posting is a long shot but just wondering if anyone else has worked through this sort of issue with raku(/perl6) - or if the error(s) I'm receiving ring a bell that might have been heard elsewhere ..

Thanks much,
wf

p.s. using chartdir 6, freebsd 12.2 (intel platform), raku 2022.04, perl 5.32.1.

1 #!/usr/bin/env raku

2 use lib:from<Perl5>  '/usr/local/lib/perl5/site_perl';
3 use Inline::Perl5;

4 my $p5 = Inline::Perl5.new;
5 $p5.use('perlchartdir') ;

6 my $data = [85, 156, 179.5, 211, 123];
7 my $labels = ["Mon", "Tue", "Wed", "Thu", "Fri"];

8 my $c = $p5.invoke( 'XYChart', 'new', 250, 250);

9 $c.setPlotArea(30, 20, 200, 200);

10 $c.addBarLayer($data);
11 $c.xAxis().setLabels($labels);
12 $c.xAxis().setLabels($labels);

13 $c.makeChart("simplebar.png");

  Re: Use of ChartDirector in Raku (formerly perl6)
Posted by Peter Kwan on Apr-27-2022 02:09
Hi wingfold,

I have never used Raku before. For your case, the methods that fail seem to be AUTOLOAD methods. For what is autoloading, see:

https://perldoc.perl.org/AutoLoader

ChartDirector for Perl is a Perl interface to the ChartDirector DLL. For every ChartDirector method in the DLL, we can declare a corresponding Perl method and forward the call to the DLL. However, this is not necessary for most of the methods. Many scripting languages (including Perl) support a "catch call" method. If a method is undefined, it will forward the call to the "catch all" method.

So most of the methods in ChartDirector are not really defined in Perl. We use the "catch all" method to forward the call to the DLL.

The "catch all" method in Perl is called "AUTOLOAD". I suspect may be Raku does not support Perl AUTOLOAD, so it reports undefined methods as not found instead of forwarding it to the "catch all" method. Or may be some additional things need to be imported for it to use the AUTOLOAD.

Regards
Peter Kwan

  Re: Use of ChartDirector in Raku (formerly perl6)
Posted by wingfold on Apr-27-2022 06:49
Peter, thanks so much for the response - this sounds right (re: autoload) and I think there is a solution - I'll report back here as I get this resolved - perhaps it will be useful for future raku'ers.   Thanks again for the fast response and support.   wf


Peter Kwan wrote:

Hi wingfold,

I have never used Raku before. For your case, the methods that fail seem to be AUTOLOAD methods. For what is autoloading, see:

https://perldoc.perl.org/AutoLoader

ChartDirector for Perl is a Perl interface to the ChartDirector DLL. For every ChartDirector method in the DLL, we can declare a corresponding Perl method and forward the call to the DLL. However, this is not necessary for most of the methods. Many scripting languages (including Perl) support a "catch call" method. If a method is undefined, it will forward the call to the "catch all" method.

So most of the methods in ChartDirector are not really defined in Perl. We use the "catch all" method to forward the call to the DLL.

The "catch all" method in Perl is called "AUTOLOAD". I suspect may be Raku does not support Perl AUTOLOAD, so it reports undefined methods as not found instead of forwarding it to the "catch all" method. Or may be some additional things need to be imported for it to use the AUTOLOAD.

Regards
Peter Kwan