[comp.lang.perl] nested packages???

tchrist@convex.com (Tom Christiansen) (11/08/90)

I just did this:

    $foo'bar'glarch = 1;

and 
    print $foo'bar'glarch;

and the right thing happened!!  In the debugger,  'V foo' says:

    %_bar = (
      glarch        'StB^S^H^PgH^A'
    )

and "V foo'bar" says nothing at all.

On the other hand, 
    $foo'bar'glarch = 'red';
followed by 
    print $foo'bar'glarch;
still says 1.

Isn't that odd?

--tom

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (11/13/90)

In article <108383@convex.convex.com> tchrist@convex.com (Tom Christiansen) writes:
: I just did this:
: 
:     $foo'bar'glarch = 1;
: 
: and 
:     print $foo'bar'glarch;
: 
: and the right thing happened!!  In the debugger,  'V foo' says:
: 
:     %_bar = (
:       glarch        'StB^S^H^PgH^A'
:     )
: 
: and "V foo'bar" says nothing at all.
: 
: On the other hand, 
:     $foo'bar'glarch = 'red';
: followed by 
:     print $foo'bar'glarch;
: still says 1.
: 
: Isn't that odd?

Not really, considering that I've never really tried to implement or test
nested packages.  There are a few hooks in there for it, but nobody's
found a good use for nested packages yet, so I haven't tried to make them
work.

Larry

flee@guardian.cs.psu.edu (Felix Lee) (11/15/90)

Nested packages don't quite work.
	package a'b; $c = 3;
	$a'b'c = 4;
	print $c;
prints 3, but
	package a'_b; $c = 3;
	$_a'b'c = 4;
	print $c
prints 4.

Apparently, package x'y uses the symbol table %_main{"__x"}{"_y"},
while $x'y'z uses the symbol table %_main{"_x"}{"__y"}.

I'd like to see nested packages work right.  The applications are
endless.  For one, I could make enums live in their own namespace if
nested packages worked correctly.  This is actually a symptom of lazy
typing; it's easier to type $color'red instead of $color_red.

One thing that's needed is a way of specifying a name relative to the
current package.  How about, $main'x is an absolute name, but $'main'x
is a name relative to the current package.  (This feels backwards
since Unix filenames follow the opposite rule...)  Does this conflict
with current practice?  $'x currently is the name "x" in the null
package.  Does anyone use the null package?
--
Felix

elw@netx.com (Edwin Wiles) (11/17/90)

In article <10341@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV
							(Larry Wall) writes:
>There are a few hooks in there for it, but nobody's found a good use for
>nested packages yet, so I haven't tried to make them work.

How about object oriented perl?  Seems to me that you could probably
do a pretty neat OOP if perl fully supported nested packages....

					Enjoy!
-- 
Prefered.: elw@netx.com				Edwin Wiles
Alternate: ...!grebyn!netex!elw			NetExpress Inc., Suite 300,
Who?  Me?!?  Responsible!?!  Surely You Jest!	Vienna, VA, USA 22182