[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Mac::Navigation glue



----------
>From: Chris Nandor <pudge@pobox.com>
>To: "Mark Yannuzzi" <myannuzzi@aya.yale.edu>
>Subject: Re: [MacPerl] Mac::Navigation glue
>Date: Fri, Apr 9, 1999, 4:54 AM
>

> At 00.11 -0400 1999.04.09, Mark Yannuzzi wrote:
>>1) Why must the use Mac::Events statement appear within the embedded
>>subroutine in order to work properly?  I tried placing it at the beginning
>>of my script with my other use statements, and got an error saying
>>DispatchEvent subroutine was undefined.  Is this, in general, necessary when
>>calling 'external' module functions/structures in embedded subroutines?
>
> use Some::Module imports symbols from that package, if any, into the
> current namespace.  Your passed subroutine is being used in a different
> namespace.
>
> Now, if you put use Mac::Events at the top of the file, and call
> Mac::Events::DispatchEvent($_[1]->event) like you did, it should work,
> becuase there is no DispatchEvent to call, only Mac::Events::DispatchEvent.

I did place use Mac::Events at the top of my file, along with
Mac::Navigation, and others. I used DispatchEvent($_[1]->event) when I got
the error, since according to footnote 4 on pg. 181 of the MacPerl book
("Because they are explicitly exported, the toolbox functions and constants
do not need to be prefixed with Mac:: before each use. ..."), I thought is
was unnecessary to use Mac::Events as a prefix.

Theoretically then ( ;) ), placing use Some::Module at the beginning of a
file will allow that module's exported entities to act like global variables
do.  Namely, that they will be 'visible' not only within the Main package of
the current file, but all other namespaces referenced from within Main.  Is
this accurate?

> Another thing to try would be something like this at the top of the program
> file:
>
>    package Mac::Navigation;  # or whatever package will be using the sub
>    use Mac::Events;
>
>    package main;
>    # now do everything else
>
> --
> Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
> %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

Thanks.
----------------------
Mark J. Yannuzzi
myannuzzi@aya.yale.edu


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org