#77: Parrot::Interpreter - should support multi-level namespaces
---------------------+------------------------------------------------------
Reporter: szabgab | Type: feature
Status: new | Priority: normal
Milestone: | Component: none
Version: trunk | Severity: medium
Keywords: | Lang:
Patch: | Platform:
---------------------+------------------------------------------------------
Comment(by szabgab):
Proposed API
The initialization should be same as now
{{{
my $parrot = Parrot::Interpreter->new();
$parrot->load_file("path/to/language.pbc");
}}}
Allowing several levels of namespaces (currently only one is supported)
{{{
my $sub_pmc = $parrot->find_global( 'name_of_sub', 'Name', 'Space' );
}}}
This is what is in the docs currently but it only accepts a single $arg
not @args
{{{
my $result_pmc = $sub_pmc->invoke( $signature, @args );
}}}
Actually I don't understand why do we need to pass the signature here as
parameter
it would be more simple to have this
{{{
my $result_pmc = $sub_pmc->invoke( @args );
}}}
But then also support these
{{{
my $result_pmc = $sub_pmc->invoke( \...@args );
my $result_pmc = $sub_pmc->invoke( \%args );
my $result_pmc = $sub_pmc->invoke( \%args, \%more_args, ... );
}}}
Some of the languages will be able to handle hash references as
parameters.
I don't understand why does it get the $interpreter as a paramater in the
docs
I think this should be enough:
{{{
my $str = $result_pmc->get_string;
}}}
But probably also
{{{
my @data = $result_pmc->get_list;
}}}
Later maybe also
{{{
$result_pmc->get_array_ref;
$result_pmc->get_hash_ref;
}}}
Later we can wrap them into something like
{{{
sub exe {
my $result_pmc = $sub_pmc->invoke( @_ );
if (wantarray) {
return $result_pmc->get_list;
} else {
return $result_pmc->get_string;
}
}
}}}
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/77#comment:2>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets