develooper Front page | perl.tcltk | Postings from March 2010

Re: Tcl_CreateSlave

Thread Previous | Thread Next
From:
Jeff Hobbs
Date:
March 19, 2010 18:04
Subject:
Re: Tcl_CreateSlave
Message ID:
4BA41EDE.7070409@activestate.com
On 19/03/2010 5:09 PM, Eric Windisch wrote:
> I feel it would be particularly useful to be able to create slave
> interpreters from Perl. This patch includes this capability and allows
> sandbox (MakeSafe) execution of Tcl code.

Patch seems to have been stripped, but can be found at 
https://rt.cpan.org/Public/Bug/Display.html?id=55717.

> Usage as follows:
>
> use Tcl;
> my $interp=Tcl::new();
> # Arbitrary name and a boolean 'safe' argument
> my $safeslave=$interp->CreateSlave('name',1);
> open (my $fh, 'script.tcl');
> $safeslave->EvalFileHandle($fh);
>
> Speaking to Jeff, he argued perhaps changing the name of the method and
> accepting a hash argument:
> <tclguy> my $interp = new Tcl;
> <tclguy> my $safeslave = $interp->interp_create(-safe => 1);

My thought is that Tcl exposes the same functionality at the Tcl level. 
Extending the C API should be kept to a minimum.  However, after talking 
to Jan it looks like you can't really bless the Tcl returned value in 
Perl because it needs the C pointer to the structure.  Thus the 
CreateSlave might be the best way to go.

Strictly speaking, in the patch you wouldn't need to register the slave 
in hvInterps because that is used to track destruction, and master 
interps will tear down their slave interps in an orderly fashion when a 
proper finalization occurs.

Jeff

Thread Previous | Thread Next


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