> In your example here, you're not using dynpmcs - you're using a PIR > class as the base; The original sample code is old enough that it > referred to the PerlString dynpmc which is no longer in core. >
Well, the problem does seem to be related to PMCs rather than high level
classes. After a discussion with pmichaud on IRC the following problems
were identified:
(1) Methods declared in the 'parrot' HLL namespace are being installed
in PMCs declared in other HLL namespaces.
(2) Methods declared in the same non-parrot HLL as a PMC are not being
installed in that PMC.
The problems seem to be manifested in both built-in PMCs and Dynamic
PMCs, but are more relevant to Dynamic PMCs which seem much more likely
to use the hll modifier and be associated with an hll namespace.
My short example using high level classes in the example in my previous
posting somewhat refutes an earlier argument that "all classes are
defined in the 'parrot' HLL namespace, not the actual HLL namespace".
At least the example may do so for high level classes.
I have updated the previous test file,
t/dynpmc/subclass_with_pir_method.t, to reflect the removal of the
PerlString pmc and the current understanding of the problem. It now
relies on the rakudo Per6Str dynamic pmc which I view as less than ideal
for unit testing.
To remove the dependency on rakudo and include tests for built-in pmcs,
I have created a new test file, a test dynamic pmc, and a test built-in
pmc. The test suite also tries method access with a subclass of a PMC
that uses an hll directive because subclassing was used in the example
that originally opened the ticket. Subclassing does not seem to change
method access behavior through different hll namespaces and without
access to the PerlString pmc used to open the ticket it is hard for me
to tell to what extent it was relevant to the problem at the time.
If a pmc has an hll modifier in its pmclass declaration, a namespace
with the name of the pmc should be installed in the hll namespace and
not the parrot namespace. That conclusion seems a reasonable extension
of the description of the problem and was discussed on IRC without
noticeable dissent. The new test suite includes a test to verify the
inclusion of the pmclass class name in the appropriate hll namespace.
The test suite and pmcs should be attached ...
Index: t/dynpmc/subclass_with_pir_method.t
===================================================================
--- t/dynpmc/subclass_with_pir_method.t (revision 37099)
+++ t/dynpmc/subclass_with_pir_method.t (working copy)
@@ -19,27 +19,23 @@
=head1 DESCRIPTION
-Tests the C<PerlString> PMC. Checks pir method execution in a dynpmc and a subclass of the pmc
+Tests the rakudo C<Perl6Str> PMC. Checks pir method execution in a dynpmc and a subclass of the pmc
=cut
-# this works
-pir_output_is(
+pir_output_isnt(
<<'CODE', <<'OUTPUT', "subclass with pir method - .loadlib", todo => "PMCs don't obey HLL namespaces" );
-.loadlib 'perl_group'
+.loadlib 'perl6_group'
.sub main :main
- new $P0, 'PerlString'
+ new $P0, 'Perl6Str'
$P0.'perl_printhi'()
- get_class $P2, 'PerlString'
+ get_class $P2, 'Perl6Str'
subclass $P0, $P2, 'NewPerlString'
- $P0.'perl_printhi'()
new $P1, 'NewPerlString'
$P1.'perl_printhi'()
.end
-.HLL 'Perl'
-.loadlib 'perl_group'
-.namespace ['PerlString']
+.namespace ['Perl6Str']
.sub 'perl_printhi' :method
print "HI from PerlString\n"
.end
@@ -47,24 +43,23 @@
CODE
HI from PerlString
HI from PerlString
-HI from PerlString
OUTPUT
pir_output_is(
<<'CODE', <<'OUTPUT', "subclass with pir method - .HLL", todo => "PMCs don't obey HLL namespaces" );
-.HLL 'Perl'
-.loadlib 'perl_group'
+.HLL 'Perl6'
+.loadlib 'perl6_group'
+
.sub main :main
- new $P0, 'PerlString'
+ new $P0, 'Perl6Str'
$P0.'perl_printhi'()
- get_class $P2, 'PerlString'
+ get_class $P2, 'Perl6Str'
subclass $P0, $P2, 'NewPerlString'
- $P0.'perl_printhi'()
new $P1, 'NewPerlString'
$P1.'perl_printhi'()
.end
-.namespace ['PerlString']
+.namespace ['Perl6Str']
.sub 'perl_printhi' :method
print "HI from PerlString\n"
.end
@@ -72,7 +67,6 @@
CODE
HI from PerlString
HI from PerlString
-HI from PerlString
OUTPUT
# Local Variables:
testhll.pmc
Description: Binary data
pmc_hll_namespace_dyn.t
Description: Troff document
testhlld.pmc
Description: Binary data
_______________________________________________ http://lists.parrot.org/mailman/listinfo/parrot-dev
