develooper Front page | perl.perl6.users | Postings from October 2018

Accessing CompUnit

From:
Richard Hainsworth
Date:
October 25, 2018 16:31
Subject:
Accessing CompUnit
Message ID:
106df844-ca01-fa41-b59e-2a00e58c782c@gmail.com
Hi,

(I am cross-posting this to stackoverflow #perl6 as well)

I am trying to create a cache of POD6 by precompiling them using the 
CompUnit set of classes.

I can create, store and retrieve pod as follows:

<code>

use v6.c;
use nqp;
my $precomp-store = 
CompUnit::PrecompilationStore::File.new(prefix=>'cache'.IO);
my $precomp = CompUnit::PrecompilationRepository::Default.new(store=> 
$precomp-store );

my $key = nqp::sha1('test.pod6');
'test.pod6'.IO.spurt(q:to/CONTENT/);
=begin pod
=TITLE More and more

Some more text

=end pod
CONTENT

$precomp.precompile('test.pod6'.IO, $key, :force);

my $handle = $precomp.load($key, )[0];

my $resurrected = nqp::atkey($handle.unit,'$=pod')[0];

say $resurrected ~~ Pod::Block::Named;

</code>

This produces the output `True`.


However, if I want to run another program that accesses the CompUnit, 
how do I re-establish the link with the CompUnit without over-writing 
previous content?


Richard



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About