I know I started the spread of the .IMPORT macros through the PIR-based test files while I was working with Sam on the SMOP prototype, but when I see sane, maintainable code using a documented interface like "find_global", replaced with a cryptic hackish macro (e.g. passing in the '_' variable just because the macro needs a temporary storage location), my code-smell warnings fire.

Let's develop a sane Export feature, and add it to the core.

Patch rejected, but ideas for a more extensive change welcomed,
Allison

Sam Vilain wrote:
Use current best practice for importing symbols in the example.
---

 runtime/parrot/library/Test/More.pir |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/runtime/parrot/library/Test/More.pir 
b/runtime/parrot/library/Test/More.pir
index 8441b25..51660ea 100644
--- a/runtime/parrot/library/Test/More.pir
+++ b/runtime/parrot/library/Test/More.pir
@@ -4,23 +4,20 @@ Test::More - Parrot extension for testing modules
=head1 SYNOPSIS + .include "hllmacros.pir"
+
+ .sub main :main
     # load this library
     load_bytecode 'library/Test/More.pir'
- # get the testing functions
-    .local pmc plan
-    .local pmc diag
-    .local pmc ok
-    .local pmc is
-    .local pmc is_deeply
-    .local pmc like
-
-    plan      = find_global 'Test::More', 'plan'
-    diag      = find_global 'Test::More', 'diag'
-    ok        = find_global 'Test::More', 'ok'
-    is        = find_global 'Test::More', 'is'
-    is_deeply = find_global 'Test::More', 'is_deeply'
-    like      = find_global 'Test::More', 'like'
+    # from hllmacros.pir
+    .local pmc _
+    .IMPORT( 'Test::More', 'plan', _ )
+    .IMPORT( 'Test::More', 'diag', _ )
+    .IMPORT( 'Test::More', 'ok', _ )
+    .IMPORT( 'Test::More', 'is', _ )
+    .IMPORT( 'Test::More', 'is_deeply', _ )
+    .IMPORT( 'Test::More', 'like', _ )
# set a test plan
     plan( 12 )
@@ -44,6 +41,7 @@ Test::More - Parrot extension for testing modules
     is_deeply( some_deep_pmc, another_deep_pmc, 'deep structure comparison' )
like( 'foo', 'f o**{2}', 'passing regex compare with diagnostic' )
+ .end
=head1 DESCRIPTION

Reply via email to